Fall Semester 2002

Midterm Exam: Stone, scissors, paper... (that's what you need for this exam)
There are two parts to this exam:
1. (Written Exam) Read the exam, turn in a solution in 75 minutes.
2. (Reality Check) Implement your solution by Tue Oct 29 5:30pm and show it next lab.
The grade for this exam will be:
• 40% the grade for the Written Part and
• 30% from the Reality Check part.
• The rest 30% part comes from the Practical Part that you should have finished already.

And now the problem.

Consider the following session with a program (`Two`) that was written in Java:

```frilled.cs.indiana.edu%javac Two.java
frilled.cs.indiana.edu%java Two
Hello and welcome to the game.
*** The computer has chosen.
Paper, scissors, or stone...
Which will it be? Type here: paper
*** The computer's choice was: paper
***(This game's a draw.)***
The score is now:
Computer: 0
You     : 0
*** The computer has chosen.
Paper, scissors, or stone...
Which will it be? Type here: scissors
Very good.
*** The computer's choice was: paper
***(So, you win.)***
The score is now:
Computer: 0
You     : 1
*** The computer has chosen.
Paper, scissors, or stone...
Which will it be? Type here: stone
*** The computer's choice was: stone
***(This game's a draw.)***
The score is now:
Computer: 0
You     : 1
*** The computer has chosen.
Paper, scissors, or stone...
Which will it be? Type here: stone
Very good.
*** The computer's choice was: scissors
***(So, you win.)***
The score is now:
Computer: 0
You     : 2
*** The computer has chosen.
Paper, scissors, or stone...
Which will it be? Type here: paper
*** The computer's choice was: scissors
***(So, you lose.)***
The score is now:
Computer: 1
You     : 2
*** The computer has chosen.
Paper, scissors, or stone...
Which will it be? Type here: frilled.cs.indiana.edu%clear```
Essentially this is the famous `stone-scissors-paper` game:

• Both you and the computer choose one of the three objects.
• `scissors` is stronger than `paper`.
• `stone` is stronger than `scissors`.
• But `paper` can wrap around the `stone`, so `paper` is stronger than `stone`.
• Entering an invalid choice makes you lose the round.
• The computer chooses first, then you choose, then the choices are compared.
• You can either
1. win a point, or
2. the computer wins a point, or
3. the game is a draw.
• If it's a draw the score stays the same.
• After each round the score has to be shown.
• The game basically can go on forever.
You are to use PHP or CGI/Perl to implement a web-based version of it.

What technologies can you use?

Any of the following:

• CGI/Perl with hidden fields
• CGI/Perl with sessions (MySQL, DBI.pm, CGI.pm)
• PHP with hidden fields
• PHP with sessions
How many implementations are needed?