Enter your guess:

"; } echo "

Guess a number!

\n"; $number = $_POST['number']; $attempts = $_POST['attempts']; $guess = $_POST['guess']; if ( $number == "") { // First attempt $real_number = rand(1,99); $number = $real_number * 352941; // to bluff View Sourche cheaters $attempts = 1; echo "

Welcome, I´ve magically chosen a number between 1 and 99 and it is your task to guess what it is!

\n"; echo_guess_form($number, $attempts); } elseif ( $guess < ($number / 352941) ) { // Guess too low $attempts = $attempts + 1; // count attempts // Array of annoying witty remarks $witty[0] = "

Too low!
$guess is too low, I think larger thoughts, you see... Try again.

\n"; $witty[1] = "

Too low!
$guess is wrong. My number is bigger than yours! Try again.

\n"; $witty[2] = "

Too low!
Hah! $guess is way too low. Do you wanna try again?

\n"; $witty[3] = "

Too low!
$guess? Little you think of me. Try again you must.

\n"; $remark = rand (0,3); echo $witty[$remark]; echo_guess_form($number, $attempts); } elseif ( $guess > ($number / 352941) ) { // Guess too hight $attempts = $attempts + 1; // count attempts // Array of annoying witty remarks $witty[0] = "

Too high!
Whoha! $guess! My number isn't that high. Try again.

\n"; $witty[1] = "

Too high!
$guess is too high. You are overambitious! Try again.

\n"; $witty[2] = "

Too high!
No! $guess is apparently too high. Do you wanna try again?

\n"; $witty[3] = "

Too high!
Not quite old chap, $guess it isn't. Be a sport and try again.

\n"; $remark = rand (0,3); echo $witty[$remark]; echo_guess_form($number, $attempts); } else { echo "

We have a winner!!!

$guess it is! You made it in $attempts attempts.
Not bad for a beginner, wanna try again?

\n"; } ?>

Back to Problem Set index page