Skip to content

Instantly share code, notes, and snippets.

@crcdng
Created April 21, 2020 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crcdng/11311b3f6691f7a268d122ed05a88d7a to your computer and use it in GitHub Desktop.
Save crcdng/11311b3f6691f7a268d122ed05a88d7a to your computer and use it in GitHub Desktop.
// http://www.99-bottles-of-beer.net/
void main() {
for (int beer = 99; beer >= 0; beer--) {
String bottles = beer > 1 ? "bottles" : "bottle";
String bottlesLeft = beer == 1 ? "no more" : (beer - 1).toString();
String leftBottles = beer == 2 ? "bottle" : "bottles";
String beerline =
'$beer $bottles of beer on the wall, $beer $bottles of beer.\nTake one down and pass it around, $bottlesLeft $leftBottles of beer on the wall.';
String lastline =
'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.';
if (beer == 0) {
print('$lastline\n');
} else {
print('$beerline\n');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment