service{ const html Welcome =

Welcome to Memoriz!

Your Name:

Play Game

HighScore

Exit ; const html Encoding = Memorize the following numbers in order. Level <[level]>

<[num1]> - <[num2]> - <[num3]> - <[num4]> - <[num5]>

Press go when you are ready!

; const html Retrieval = It's your turn NOW!

Please write down the numbers here in original order:

- - - - ; const html Go2NextLevel = Original Numbers: <[num1]> - <[num2]> - <[num3]> - <[num4]> - <[num5]>

Your Answer: <[ans1]> - <[ans2]> - <[ans3]> - <[ans4]> - <[ans5]>

Congratulations! You have been upgraded to Level <[level]>!

Your current score is <[score]> ; const html HighScore = High Score!

Current HIGH Score is <[highScore]>, by <[holder]>. ; const html GameOver = Sorry, <[name]>. your anwser is wrong...

Original Numbers: <[num1]> - <[num2]> - <[num3]> - <[num4]> - <[num5]>

Your Answer: <[ans1]> - <[ans2]> - <[ans3]> - <[ans4]> - <[ans5]>

Your final score is <[score]>. You are in Level <[level]>.


GAME OVER :P


; const html Fin = Thank you for play the game!

<[name]>

Your final score is <[score]>

HIGH score is <[highScore]> ; schema player { int score; string name; } int seed; tuple player hi; int nextRandom() { seed = (25173 * seed + 13849) % 65536; return(seed); } session Play() { string choice; int num1, num2, num3, num4, num5, ans1, ans2, ans3, ans4, ans5; int level, factor; tuple player pl; int index; choice = "exit"; show Welcome receive[choice = choice, pl.name = name]; while(choice != "exit"){ if (choice == "highscore") show plug HighScore[highScore = hi.score, holder = hi.name]; else if (choice == "play"){ level = 1; factor = 10; pl.score = 0; while (level <= 5){ num1 = nextRandom() % factor; num2 = nextRandom() % factor; num3 = nextRandom() % factor; num4 = nextRandom() % factor; num5 = nextRandom() % factor; factor = factor * 5; show plug Encoding [num1 = num1, num2 = num2, num3 = num3, num4 = num4, num5 = num5, level = level]; show Retrieval receive [ans1 = ans1, ans2 = ans2, ans3 = ans3, ans4 = ans4, ans5 = ans5]; if ((ans1 == num1) && (ans2 == num2) && (ans3 == num3) && (ans4 == num4) && (ans5 == num5)) { pl.score = 10 * level + pl.score; level = level +1; show plug Go2NextLevel [num1 = num1, num2 = num2, num3 = num3, num4 = num4, num5 = num5, ans1 = ans1, ans2 = ans2, ans3 = ans3, ans4 = ans4, ans5 = ans5, level = level, score = pl.score]; } else { show plug GameOver [num1 = num1, num2 = num2, num3 = num3, num4 = num4, num5 = num5, ans1 = ans1, ans2 = ans2, ans3 = ans3, ans4 = ans4, ans5 = ans5, level = level, score = pl.score, name = pl.name]; level = 10; } } } if (hi.score <= 0||pl.score >= hi.score) { hi.score = pl.score; hi.name = pl.name; } show Welcome receive[choice = choice, pl.name = name]; } exit plug Fin [score = pl.score, name = pl.name, highScore = hi.score]; } session HiScore() { exit plug HighScore[highScore = hi.score, holder = hi.name]; } }