|
Spring Semester 2005 |
Also, please make sure you
the Computer Science Department's Statement on Academic Integrity before turning in your assignment.
CGI.pm)
that behaves just like this. Recognize that a more precise specification is needed (finite state automaton).
A distinct
implementation of the Midterm Exam is also acceptable.
A distinct stage of the
Semester Project also qualifies for credit.
Determine
what this program is supposed to do and make it do it:
#!/usr/bin/perl
# state is ________ of:
# $mess___
# $____Score
# $user_____
# $comp______
# _____ is provided by the:
# $user
print qq{Content-type: ____/____\n\n};
$in = $ENV{____________}; # what if it's POST?
@_____ = split(/&/, $in);
foreach $____ (@pairs) {
($nam, $___) = split(/=/, $pair);
$in{$___} = $val;
}
# foreach $k (keys %in){
# print $k, " --> ", $in{$k}, "<p>";
# }
$message = $in{message};
$compScore = ______________;
$userScore = $in{userScore};
$__________ = $in{compChoice};
if (________) {
$user = $__{user};
if (($user + 1) % 3 == $compChoice) {
$message = "________";
$_________ += 1;
} elsif (($__________ + 1) % 3 == $user) {
$message = "You lose.";
$compScore __ _;
} else {
$message = "This is a tie.";
}
$compChoice = ____________;
} else {
$_______ = "Welcome.";
$compScore = 0;
$userScore = 0;
$compChoice = ___(rand(3));
}
print qq{
<form method=GET action=_________________>
$message <p>
The computer has chosen: $compChoice, now it's your ____. <p>
<table border><tr><td> ________ <td> User
<tr><td> $compScore <td> $userScore </table> <p>
What: <select name="user">
<option value="0"> _____
<option value=___> Rock
<______ value="2"> Scissors
</select> <p>
When finished please press <input type="submit" value="Proceed"> <p>
<_____ type="hidden" name="compScore" value="$compScore">
<input type="______" name="_______" value="$message">
<input type="hidden" name="userScore" value="__________">
<input type="hidden" ____="compChoice" value="$compChoice">
</form>
};