Sha256: b55a2cbd7a17bbafa45c5eb8ff33886c19c9383ecb44a929d1d7fbca5c07eb18

Contents?: true

Size: 1.15 KB

Versions: 134

Compression:

Stored size: 1.15 KB

Contents

public class BeerSong {
    public static 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 static 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 static String singSong() {
        return sing(99,0);
    }
}

Version data entries

134 entries across 134 versions & 1 rubygems

Version Path
trackler-2.0.8.34 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.33 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.32 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.31 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.30 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.29 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.28 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.27 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.26 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.24 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.23 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.22 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.21 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.20 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.19 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.18 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.17 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.16 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.15 tracks/java/exercises/beer-song/src/example/java/BeerSong.java
trackler-2.0.8.14 tracks/java/exercises/beer-song/src/example/java/BeerSong.java