Sha256: cd2ef6701c9ac708ce7aa6cd2580d573d0fb97a96117ce6f500440f7efd3dec3

Contents?: true

Size: 1.11 KB

Versions: 150

Compression:

Stored size: 1.11 KB

Contents

public class BeerSong {
    public String verse(int number) {
        switch (number) {
            case 0:
                return "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n\n";
            case 1:
                return "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n\n";
            case 2:
                return "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n\n";
            default:
                return String.format("%d bottles of beer on the wall, %d bottles of beer.\nTake one down and pass it around, %d bottles of beer on the wall.\n\n", number, number, number - 1);
        }
    }

    public String sing(int start, int stop) {
        StringBuilder songOutput = new StringBuilder();

        for (int i=start; i>=stop; i--) {
            songOutput.append(verse(i));
        }

        return songOutput.toString();
    }

    public String singSong() {
        return sing(99,0);
    }
}

Version data entries

150 entries across 150 versions & 1 rubygems

Version Path
trackler-2.2.1.66 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.65 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.64 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.63 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.62 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.61 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.60 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.59 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.58 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.57 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.56 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.55 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.54 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.53 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.52 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.51 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.50 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.49 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.48 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java
trackler-2.2.1.47 tracks/java/exercises/beer-song/.meta/src/reference/java/BeerSong.java