service {
const html AdminPass =
You will need a password to change the values:
password:
;
const html PassWrong =
Don't try that again!!!
;
const html AdminUpdate =
Hi Master:
component1:
component2:
component3:
component4:
;
const html Prices =
- <[comp1]> <[price1]>
- <[comp2]> <[price2]>
- <[comp3]> <[price3]>
- <[comp4]> <[price4]>
If you have a better price don't hesitate to give us a better price:
You have found a better price for component:
;
const html Update =
So you have found a better price for <[comp]>:
Feel free to give us your new price:
;
const html Done =
The price was updated.
;
const html DoneAdmin =
The prices and names were updated.
;
const html Kidding =
You are kidding? The old price was better!
;
string comp1, comp2, comp3, comp4;
int price1, price2, price3, price4;
session Admin() {
string pass;
show AdminPass receive [pass=pass];
if (pass != "pass")
show PassWrong;
else
{
show AdminUpdate receive [comp1 = comp1, comp2 = comp2, comp3 = comp3, comp4 = comp4, price1 = price1, price2 = price2, price3 = price3, price4 = price4];
}
}
session Price() {
string comp;
int newPrice;
while(true) {
show plug Prices[comp1 = comp1, comp2 = comp2, comp3 = comp3, comp4 = comp4, price1 = price1, price2 = price2, price3 = price3, price4 = price4] receive [comp = comp];
if (comp == comp1) {
show plug Update[comp = comp] receive [newPrice = newPrice];
if (newPrice <= price1) {
price1=newPrice;
show Done;
}
else
show Kidding;
}
if (comp == comp2) {
show plug Update[comp = comp] receive [newPrice = newPrice];
if (newPrice <= price2) {
price2=newPrice;
show Done;
}
else
show Kidding;
}
if (comp == comp3) {
show plug Update[comp = comp] receive [newPrice = newPrice];
if (newPrice <= price3) {
price3=newPrice;
show Done;
}
else
show Kidding;
}
if (comp == comp4) {
show plug Update[comp = comp] receive [newPrice = newPrice];
if (newPrice <= price4) {
price4=newPrice;
show Done;
}
else
show Kidding;
}
}
}
}