service { const html Login = Username:

Password:

; const html Welcome = Name:

Time:

; const html Result =

The appointment for <[name]> on <[weekday]> <[timeofday]> is reserved.

; const html FailLogin = Illegal user! ; const html Error = Internal Error. ; schema Appointment { string name; string weekday; string timeofday; } schema User { string username; string password; } tuple User guest, admin; int seed; bool login(string user, string pass) { bool result; result = ( (user == guest.username && pass == guest.password) || (user == admin.username && pass == admin.password) ); return (result); } session Reserve() { string weekday, timeofday; int i, failLogin; string username, password, aa; tuple Appointment app; guest = tuple {username="guest", password="guest"}; admin = tuple {username="admin", password="admin"}; show Login receive[username = username, password = password]; failLogin = 1; while (!login(username, password) && failLogin < 3) { show Login receive [username = username, password = password]; failLogin = failLogin + 1; } if (failLogin >= 3) { exit FailLogin; } else { show Welcome receive [app.name = name, app.weekday = weekday, app.timeofday = timeofday]; exit plug Result [name = app.name, weekday = app.weekday, timeofday = app.timeofday]; } } }