function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jim BoudreauxJim Boudreaux 

Force.com Developer Drinking Song

Force.com Developers can have fun too! :)

 

 

<apex:page showHeader="false" controller="drinkingsong">
  <apex:repeat value="{!song}" var="s">
      {!s}<br/>
  </apex:repeat>
</apex:page>

public class drinkingsong {
    public String stanza(integer bottles){
        string stanza1;
        string stanza2;
        string stanza;
        if (bottles > 1){
            stanza1 = bottles + ' bottles of beer on the wall, ' + bottles +' bottles of beer. Take one down pass it around, ';
            bottles = bottles - 1;
            stanza2 = bottles + ' bottles of beer on the wall.';
        }else if(bottles == 1){
            stanza1 = '1 bottle of beer on the wall, 1 bottle of beer. Take one down pass it around, ';
            stanza2 = 'No more bottles of beer on the wall. ';
        }
        stanza = stanza1 + stanza2;
        return stanza;
    }

    public List<string> getSong(){
        integer bottles = 99;
        List<string> song = new List<string>();
   
        while (bottles > 0){
            string stanza = stanza(bottles);
            song.add(stanza);
            bottles = bottles - 1;
        }
        return song;
    }
}	

 

 

Tran ManTran Man

This totally tops a java haiku I came across in the past.  Keep it up!