Created
April 21, 2020 08:35
-
-
Save crcdng/11311b3f6691f7a268d122ed05a88d7a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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