Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Definer

(object-oriented version)

Date:04/20/05
Author:Chris Sauls
URL:n/a
Comments:0
Info:n/a
Score: (2.92 in 102 votes)
\{
	 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

Alternative Versions

VersionAuthorDateCommentsRate
standard versionChris Sauls04/20/050

Comments

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!

Name:

eMail:

URL:

Security Code:
  
Comment: