Language Ferite
(Objects)
| Date: | 09/25/06 |
| Author: | Rowan Lewis |
| URL: | http://pixelcarnage.net/ |
| Comments: | 1 |
| Info: | http://ferite.org/ |
| Score: |
class BottlesOfBeerSong {
private number bottles;
private string output;
private string format;
constructor(number bottles) {
self(bottles, "html");
}
constructor(number bottles, string format) {
.bottles = bottles;
.format = format;
}
function play() {
while (.bottles > 0) {
string bottles = "bottle";
.start();
if (.bottles > 1) {
bottles += "s";
}
.line("${.bottles} ${bottles} of beer on the wall,");
.line("${.bottles} ${bottles} of beer,");
.line("Take one down, pass it around,");
.bottles--;
if (.bottles > 0) {
.line("${.bottles} ${bottles} of beer on the wall.");
} else {
.line("No bottles of beer on the wall!");
}
.stop();
}
return .output;
}
private function start() {
if (.format == "html") {
.output += "\n<p>";
}
}
private function line(string line) {
if (.format == "html") {
.output += "\n\t${line}<br />";
} else {
.output += "\n${line}";
}
}
private function stop() {
if (.format == "html") {
.output = .output[..-7] + "\n</p>";
}
}
}
object song = new BottlesOfBeerSong(99);
Console.println("" + song.play());
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