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 QVT

(Operational Mappings)

Date:05/10/10
Author:Alexander Trenz
URL:n/a
Comments:0
Info:http://www.omg.org/spec/QVT/1.0/
Score: (1.67 in 3 votes)
/*
 *
 * M2M - Operational QVT - V2.0.1
 *
 */

transformation ninety_nine_bottles_of_beer();

main(){
	
	map startSong();	
}


mapping startSong(){

	var bottles : Integer := 99;
	
	while(bottles>0){
	
		if(bottles>2)
		then{
		
			log(bottles.repr() + ' bottles of beer on the wall, ' + bottles.repr() + 
								 ' bottles of beer.' + '\n' + 
								 'Take one down and pass it around, '+ 
								  (bottles-1).repr() + ' bottles of beer on the wall.' + '\n');
		}	
		endif;
		
		if (bottles=2) 
		then{
			log(bottles.repr() + ' bottles of beer on the wall, ' + bottles.repr() + 
								 ' bottles of beer.' + '\n' + 
			'Take one down and pass it around, '+  (bottles-1).repr() + 
			' bottle of beer on the wall.' + '\n');
		}
		else{
			 log(bottles.repr() + ' bottle of beer on the wall, ' + bottles.repr() + 
								  ' bottle of beer.' + '\n' + 
			 'Take one down and pass it around, no more bottles of beer on the wall.' + '\n');
		}
		endif;
		
		bottles := bottles-1;
	};
	
	map endSong();
}

mapping endSong(){

	log('No more bottles of beer on the wall, no more bottles of beer.' + '\n' + 
		'Go to the store and buy some more, 99 bottles of beer on the wall.');
}

Download Source | Write Comment

Alternative Versions

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: