Permalink
Browse files

beer-song: Adding beer song problem

  • Loading branch information...
jeseekia committed Jul 7, 2016
1 parent 675bbe1 commit 61b8773cb380e77ef77cdbb9ebfa9846c17b2c71
@@ -41,7 +41,8 @@
"simple-linked-list",
"linked-list",
"nth-prime",
"pascals-triangle"
"pascals-triangle",
"beer-song"
],
"deprecated": [
],
@@ -0,0 +1,11 @@
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"
repositories {
mavenCentral()
}
dependencies {
testCompile "junit:junit:4.10"
}
@@ -0,0 +1,31 @@
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);
}
}
@@ -0,0 +1,3 @@
public class BeerSong {
}

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -28,9 +28,7 @@
{"5", 0},
{"9", 0},
{"134678", 0},
{"abc10", 0},
{"10z", 0},
{"10a10", 0},
{"abc10z", 0},
{"011", 3}
});
}
@@ -3,6 +3,7 @@ include 'acronym'
include 'allergies'
include 'anagram'
include 'atbash-cipher'
include 'beer-song'
include 'binary'
include 'bob'
include 'crypto-square'

0 comments on commit 61b8773

Please sign in to comment.