Guess a Number

due: Tuesday 1/27
points: 50

Game Play

The computer picks a number between 1 and 1000. It is the user's job to guess that number.

When the user guesses a number, the computer tell the user if the number was correct, too high, too low, already guessed or out of bounds. You may assume that the user actually types an integer.

When the game is over, the computer should produce some feedback for the user.


Sample Execution

You have 10 guesses remaining.
Enter a number between 1 and 1000: 500
Your guess is too high.
You have 9 guesses remaining.
Enter a number between 1 and 1000: 250
Your guess is too high.
You have 8 guesses remaining.
Enter a number between 1 and 1000: 125
Your guess is too low.
You have 7 guesses remaining.
Enter a number between 1 and 1000: 187
Your guess is too low.
You have 6 guesses remaining.
Enter a number between 1 and 1000: 211
Your guess is too low.
You have 5 guesses remaining.
Enter a number between 1 and 1000: 211
You already tried that one.
You have 4 guesses remaining.
Enter a number between 1 and 1000: 231
Your guess is too low.
You have 3 guesses remaining.
Enter a number between 1 and 1000: 241
Your guess is too low.
You have 2 guesses remaining.
Enter a number between 1 and 1000: 246
Your guess is too low.
You have 1 guesses remaining.
Enter a number between 1 and 1000: 248
Your guess is too high.
You ran out of guesses. The correct number is 247
You guessed 10 times.
Your guesses were: 500 250 125 187 211 211 231 241 246 248

Implementation Notes


Grading

The program will be worth 50 points.
Topic Points Description
Code Format 3

Use good indenting. Don't have more than 80 characters on a single line. Use consistent capitalization. Generally, variables and function names are lower case. User defined types (such as classes) start with a capital letter. Constants are all capital letters.

Code Documentation 5

Although comments are important in making your code readable, you also want to make sure you use good, descriptive variable and function names. Certain variables, like the automatic variable "i" in a for loop can have short, commonly used names. Functions and method names should usually be verb phrases e.g. getTimeOfDay() and isGameOver().

You should also avoid magic "numbers" whenever reasonable to do so, use constants instead. The use of 0 or 1 is usually okay, but values such as 6, 3562 or '?' probably have some interesting meaning in your program and a (const) variable name is a great way to describe it.

Game Specifications 35

The game runs more or less as described. You may make modifications in the specifications in order to satisfy the functionality and creativity portion of the assignments.

Functionality and Creativity 5

You MUST include some additional feature(s) in your game.

Creativity 2

Incorporate your own style into the features or the display of the game. I would give you suggestions, but that would be missing the point.

Code that does not compile will get at most 5/50.

Submission

You will need to submit the following files via the assignment page in Moodle. Do NOT submit your entire eclipse project folder.
  1. Any .cpp or .h files you (or eclipse) created for the project.
  2. A README file containing:

Clif Presser<cpresser@gettysburg.edu>
Last modified: Thu Jan 22 06:44:46 EST 2015