Programming Assignment 04
Bulls and Cows, pt. 2
Due: Wednesday, October 3rd [8:00 AM for code and 9:00
AM for paperwork]
Your Assignment
This week, your goal is to modify your Bulls and Cows program from PA03 so
that it has the following functionality (Lines in black are repeats from PA03.
Lines in red are modifications).
- The code-maker is the computer while the code-breaker is the human player.
- The code-maker comes up with a length FIVE code.
- The code is selected from the character set { B, G,
R, Y, O }
- Before the code-maker picks the code, (s)he asks the
code-breaker if the game is going to be played in
- easy mode - no character in the code can repeat
- hard mode - repeating is allowed
- After each guess, the code-maker checks to see if the guess is the secret
code.
- It it is, then the game prints a congratulations method.
- If it is not, then the the game provides a Bulls/Cows evaluation as it
did before.
- In the middle of a game, the code-breaker can enter "quit" or "QUIT" This
should cause the code-maker to print a goodbye message which includes the
answer to the secret code.
- In the middle of a game, the code-breaker can enter
"history" or "HISTORY" This should cause the code-maker to print a well
formatted sequence of text which reviews each guess that the code-breaker has
made during that game AND the bulls/cows evaluation of that guess.
- If at any time the code-breaker enters something OTHER than the quit
command or a valid code, the code-maker should remind the code-breaker about
valid options. For example, a guess of "ABCDE" or "bgryo" should generate
a message reminding the player that only BGRYO are valid characters.
- The code-breaker is only allowed to make 8 guesses.
The code-maker keeps track of "what number" each guess is (probably reminding
the code-breaker as the game progresses). If the code is guessed within
8 guesses, the code-breaker wins. If the code is NOT guessed by the 8th
guess, the code-maker wins.
- After each game is completed, the computer asks if the human would like to
play again. If the answer is yes, a new game starts (by asking which
mode). If the answer
is no, then a goodbye message is printed.
Make sure that your program provides this basic functionality.
You may choose to refactor and modify your code from PA03, but you may also
choose to start over from scratch if your original submission was not
appropriate.
Deliverables
By the due date and time, submit the files:
- a cover report. (electronically, call this "readme.txt) This
should document your design and describe each of the classes in your solution
in some meaningful manner. This report should also describe how to use
the program both from the player's point of view.
- BullsAndCows.java, the "driver" class (the class that
contains main() ).
- any other files you create, in the order listed on your cover sheet
via the electronic submission system. You will also need to prepare
your documentation packet following the
homework collection
policies.