service {
const html WallView =
<[wallNum]> bottles of beer on the wall, <[wallNumCopy]> bottles of beer...
The wall currently says: <[wallMsg]>
Your inebriated contribution:
;
const html EmptyWall =
The wall is empty...ask the beer gods to run the restock session.
;
const html Restocked = Drive safely.;
schema Wall {
int num;
string msg;
}
tuple Wall w;
int inc(int x) {
return x+1;
}
int dec(int x) {
return x-1;
}
session Restock() {
w.num = 99;
w.msg = "Kilroy is on vacation...he'll be here later. ";
exit Restocked;
}
session BeerWall() {
string choice, write;
while(w.num > 0) {
show plug WallView [wallNum=w.num, wallNumCopy=w.num, wallMsg=w.msg] receive [choice=choice,write=write];
if( (choice=="pass") || (choice=="drink") ) {
w.num = dec(w.num);
}
else if(choice=="put") {
w.num = inc(w.num);
}
w.msg = w.msg + " -- " + write;
}
exit EmptyWall;
}
}