Language ObjectScript
| Date: | 04/20/06 |
| Author: | Christian Meurin |
| URL: | n/a |
| Comments: | 0 |
| Info: | http://objectscript.sourceforge.net/ |
| Score: |
// ObjectScript is a language for the Java VM that resembles a sort of
// simplified JavaScript. The language is small and easy to learn, yet
// powerful to utilize. It is licensed under LGPL.
//
// http://objectscript.sourceforge.net/
/**
* This demonstrates how ObjectScript can distinguish a function as a class.
* The code contained within that comes before the nested functions (treated
* as class methods) is considered class constructor code.
*
* @author Christian Meurin
* @version 1.0
*/
public function BottlesOfBeer() extends Object {
public const var BEERMAX = 99;
public const var LOWBEER = 1;
public var beerCount;
public function letsDoIt() {
beerCount = BEERMAX;
while (beerCount >= LOWBEER) {
if (beerCount != LOWBEER) {
writeln(beerCount + " bottles of beer on the wall,\n");
writeln(beerCount + " bottles of beer.\n");
} else {
writeln("One more bottle of beer on the wall,\n");
writeln("One more bottle of beer.\n");
}
writeln("Take one down, pass it around,\n");
// Using if statement since ObjectScript doesn't have switch-case
// statement.
if (beerCount > LOWBEER) {
writeln(beerCount + " more bottles of beer on the wall.\n");
} else if (beerCount == LOWBEER) {
writeln("One more bottle of beer on the wall.\n");
} else {
writeln("No more bottles of beer on the wall.\n");
}
}
writeln("Ugh! I think I'm gonna be sick...");
}
}
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