Language Definer
(object-oriented version)
| Date: | 04/20/05 |
| Author: | Chris Sauls |
| URL: | n/a |
| Comments: | 0 |
| Info: | n/a |
| Score: |
\{
Program: :99 Bottles (OO Version)
Platform: :Definer (Console)
Author: :Chris Sauls
Date: :06.03.2003
\}
include std console *;
include std wrap list array *;
define class bottle {
define public routine Take {
Console:WriteLine ("Take one down, pass it around.\n");
}
}
define class shelf {
define private bottle array {
Bottles = 99 ** (new bottle ());
}
define public routine TakeOne {
Bottles:Extract(0):Take;
}
define public routine Report {
Console:WriteLine (Bottles.Length, " bottles of beer");
}
define public condition boolean Empty {
return Bottles.Length == 0;
}
}
define shelf {
Shelf = new shelf ();
}
\{ Main Routine \}
{
until Shelf.Empty {
Console:WriteLine (Shelf:Report, " on the wall.\n");
Console:WriteLine (Shelf:Report, ".\n");
Shelf:TakeOne;
Console:WriteLine (Shelf:Report, " on the wall.\n");
}
Console:WriteLine ("No more bottles of beer on the wall.\n");
}
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments