Editing Program:Jugs of Cider 1 You are editing an old version of this page. If you save it, any changes made since this version will be lost. You are editing an old version of this page. If you save it, any changes made since this version will be lost. You are not logged in. The rich text editor does not work with JavaScript switched off. Please either enable it in your browser options, or visit your preferences to switch to the old MediaWiki editor The '''Jugs of Cider''' program is a good one for testing the syntax of a complete program. The goal is to print out [http://www.99-bottles-of-beer.net/lyrics.html the 99 Jugs of Cider song]. The below implementation includes an [[import]], a [[superclass]], an implemented [[interface]], multiple [[methods]], [[variables]], [[literals]], different types of [[nesting|nested]] [[branching statements]], and [[comments]]. == Example == {{codeblock| {{code|keyword|Remember when I wrote about}}{{code|whitespace| }}{{code|class|Applejack}}{{code|punctuation|?}}{{code|whitespace| }}{{code|comment|(I don't!)}}{{code|whitespace|<BR /><BR />}}{{code|keyword|Dear}}{{code|whitespace| }}{{code|class|Princess Cadence}}{{code|whitespace| }}{{code|keyword|and}}{{code|whitespace| }}{{code|class|Shining Armor}}{{code|punctuation|:}}{{code|whitespace| }}{{code|class|Cider Jugs}}{{code|punctuation|.}}{{code|whitespace|<BR /><BR />}}{{code|keyword|Today I learned}}{{code|whitespace| }}{{code|method|Applejack's Drinking Song}}{{code|punctuation|.}}{{code|whitespace|<BR />}}{{code|keyword|Did you know that}}{{code|whitespace| }}{{code|variable|Applejack}}{{code|whitespace| }}{{code|keyword|likes}}{{code|whitespace| }}{{code|type|the number}}{{code|whitespace| }}{{code|literal|99}}{{code|punctuation|?}}{{code|whitespace| }}{{code|comment|(Applejack likes a lot of things...)}}{{code|whitespace|<BR />}}{{code|keyword|I remembered}}{{code|whitespace| }}{{code|method|how to sing the drinking song}}{{code|whitespace| }}{{code|keyword|using}}{{code|whitespace| }}{{code|variable|Applejack}}{{code|punctuation|.}}{{code|whitespace|<BR />}}{{code|keyword|That's all about}}{{code|whitespace| }}{{code|method|Applejack's Drinking Song}}{{code|punctuation|!}}{{code|whitespace|<BR /><BR /><BR /><BR />}}{{code|keyword|I learned}}{{code|whitespace| }}{{code|method|how to sing the drinking song}}{{code|whitespace| }}{{code|keyword|using}}{{code|whitespace| }}{{code|type|the number}}{{code|whitespace| }}{{code|variable|ciders}}{{code|punctuation|.}}{{code|whitespace|<BR />}}{{code|keyword|As long as}}{{code|whitespace| }}{{code|variable|ciders}}{{code|whitespace| }}{{code|comparator|were more than}}{{code|whitespace| }}{{code|literal|1}}{{code|punctuation|.}}{{code|whitespace|<BR />}}{{code|keyword|I sang}}{{code|whitespace| }}{{code|variable|ciders}}{{code|literal|" jugs of cider on the wall, "}}{{code|variable|ciders}}{{code|literal|" jugs of cider,"}}{{code|punctuation|.}}{{code|whitespace|<BR />}}{{code|operator|There was one less}}{{code|whitespace| }}{{code|variable|ciders}}{{code|punctuation|.}}{{code|whitespace|<BR />}}{{code|keyword|When}}{{code|whitespace| }}{{code|variable|ciders}}{{code|whitespace| }}{{code|comparator|had more than}}{{code|whitespace| }}{{code|literal|1}}{{code|punctuation|,}}{{code|whitespace| }}{{code|keyword|I sang}}{{code|whitespace| }}{{code|literal|"Take one down and pass it around, "}}{{code|variable|ciders}}{{code|literal|" jugs of cider on the wall."}}{{code|punctuation|!}}{{code|whitespace|<BR />}}{{code|keyword|Otherwise}}{{code|punctuation|,}}{{code|whitespace| }}{{code|keyword|I sang}}{{code|whitespace| }}{{code|literal|"Take one down and pass it around, 1 jug of cider on the wall."}}{{code|punctuation|!}}{{code|whitespace|<BR />}}{{code|keyword|That's what I would do}}{{code|punctuation|,}}{{code|whitespace| }}{{code|keyword|That's what I did}}{{code|punctuation|.}}{{code|whitespace|<BR /><BR />}}{{code|keyword|I sang}}{{code|whitespace| }}{{code|literal|"1 jug of cider on the wall, 1 jug of cider.<BR />Take it down and pass it around, no more jugs of cider on the wall.<BR /><BR />No more jugs of cider on the wall, no more jugs of cider.<BR />Go to the celler, get some more, 99 jugs of cider on the wall."}}{{code|punctuation|.}}{{code|whitespace|<BR />}}{{code|keyword|That's what I did}}{{code|punctuation|.}}{{code|whitespace|<BR />}}{{code|keyword|That's all about}}{{code|whitespace| }}{{code|method|how to sing the Drinking Song}}{{code|punctuation|!}}{{code|whitespace|<BR /><BR />}}{{code|keyword|Your faithful student}}{{code|punctuation|,}}{{code|comment| Twilight Sparkle}}{{code|punctuation|.}}{{code|whitespace|<BR /><BR />}}{{code|comment|P.S. Twilight's drunken state truely frightened me, so I couldn't disregard her order to send you this letter. Who would have thought her first reaction to hard cider would be this... explosive? I need your advice, your help, everything, on how to deal with her drunk... self. -Spike}}}} === As a Scroll === Here's the same program written for Layman's readability: <BLOCKQUOTE style="font-family:cursive, serif;"> <P>Remember when I wrote about Applejack? (I don't!)</P> <P>Dear Princess Cadence and Shining Armor: Cider Jugs.</P> <P STYLE="text-indent:0.5in">Today I learned Applejack's Drinking Song. Did you know that Applejack likes the number 99? (Applejack likes a lot of things...) I remembered how to sing the drinking song using Applejack. That's all about Applejack's Drinking Song!</P> <P STYLE="text-indent:0.5in">I learned how to sing the drinking song using the number ciders. As long as ciders were more than 1, I sang cider" jugs of cider on the wall, "cider" jugs of cider,". There was one less cider. When cider had more than 1, I sang "Take one down and pass it around, "cider" jugs of cider on the wall."! Otherwise, I sang "Take one down and pass it around, 1 jug of cider on the wall."! That's what I would do, That's what I did.</P> <P STYLE="text-indent:0.5in">I sang "1 jug of cider on the wall, 1 jug of cider. Take it down and pass it around, no more jugs of cider on the wall. No more jugs of cider on the wall, no more jugs of cider. Go to the celler, get some more, 99 jugs of cider on the wall.". That's what I did! That's all about how to sing the Drinking Song!</P> <P>Your faithful student,<br />Twilight Sparkle.</P> <P>P.S. Twilight's drunken state truely frightened me, so I couldn't disregard her order to send you this letter. Who would have thought her first reaction to hard cider would be this... explosive? I need your advice, your help, everything, on how to deal with her drunk... self. -Spike</P> </BLOCKQUOTE> Loading editor Below are some commonly used wiki markup codes. Simply click on what you want to use and it will appear in the edit box above. Insert: – — … ° ≈ ≠ ≤ ≥ ± − × ÷ ← → · § Sign your username: ~~~~ Wiki markup: {{}} | [] [[]] [[Category:]] #REDIRECT [[]] <s></s> <sup></sup> <sub></sub> <code></code> <blockquote></blockquote> <ref></ref> {{Reflist}} <references/> <includeonly></includeonly> <noinclude></noinclude> {{DEFAULTSORT:}} <nowiki></nowiki> <!-- --> <span class="plainlinks"></span> Symbols: ~ | ¡ ¿ † ‡ ↔ ↑ ↓ • ¶ # ¹ ² ³ ½ ⅓ ⅔ ¼ ¾ ⅛ ⅜ ⅝ ⅞ ∞ ‘ “ ’ ” «» ¤ ₳ ฿ ₵ ¢ ₡ ₢ $ ₫ ₯ € ₠ ₣ ƒ ₴ ₭ ₤ ℳ ₥ ₦ № ₧ ₰ £ ៛ ₨ ₪ ৳ ₮ ₩ ¥ ♠ ♣ ♥ ♦ View this template This field is a spam trap. DO NOT fill it in! Edit summary Preview Mobile Desktop Show changes