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 XOTcl

(Example using XOTcl specific constructs)

Date:03/19/06
Author:Mark Janassen
URL:n/a
Comments:0
Info:http://media.wu-wien.ac.at/
Score: (1.50 in 4 votes)
package require XOTcl

namespace import ::xotcl::*

Class SingleBottle 

SingleBottle instproc go {} {
   puts -nonewline "1 bottle of beer on the wall, "
   puts "1 bottle of beer."
   puts -nonewline "Take one down, pass it around, "
   puts "no bottles of beer on the wall.\n"
} 

Class Beerwall -parameter number

Beerwall instproc go {} {
  puts -nonewline "[my number] bottles of beer on the wall, "
  puts "[my number] bottles of beer."
  puts -nonewline "Take one down, pass it around, "
  set number [expr {[my number] - 1}]
  set b [Beerwall new -number $number]
  if {[$b number] == 1 } { 
	$b mixin SingleBottle ; puts "1 bottle of beer on the wall."
  } else {
	puts "$number bottles of beer on the wall."
 }
  $b go  
}

set b [Beerwall new -number 99]
puts [$b number]
$b go

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
1Philipp Winterberg04/20/053

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: