-
Notifications
You must be signed in to change notification settings - Fork 0
Prajna-Ramamurthy/Mastermind-Java
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
# PROJECT TITLE: Mastermind
PURPOSE OF PROJECT: Project for ICSE X STD
VERSIONE: Version 1.0
HOW TO START THIS PROJECT: Run the main funtion in Class Main from BlueJ
Pass true as parameter if the code set by computer has to be shown to
the user. This helps in testing if computer is generating the correct
feedback for the guesses entered by the user.
AUTHOR: PRAJNA R (Class X A1)
USER INSTRUCTIONS:
Master Mind is a code-breaking game for two players - a code maker and
a code breaker. With four positions and six colors, there are 64 = 1296
different patterns (allowing duplicate colors). Varying the number of
colors and the number of positions results in a spectrum of Mastermind
games of different levels of difficulty.
In this program, computer plays the role of code maker and user plays
the role of code breaker. Code maker (computer) creates a code consisting
of 4 or more colors at specific positions, but does not reveal the code
to code breaker (user). Code breaker tries to guess the pattern, in both
order and color, within x turns, where x is determined based on the
difficulty level. Each guess is made by the user by typing first letter of
the colors, for example, BRYP. Once code is typed, the code maker provides
feedback by displaying Black and White. Black is displayed for each color
from the guess which is correct in both color and position. White
indicates the existence of a correct color, but placed in the wrong
position. Once feedback is provided, another guess is made by the user;
guesses and feedback continue to alternate until either the code breaker
guesses correctly, or twelve (or ten, depending on difficulty level)
incorrect guesses are made.
The program has the following classes: -
1. Main - displays menu and accepts user’s input. Menu consists of:
a. starting the game,
b. viewing game rules,
c. setting difficulty levels,
d. display score board,
e. displaying information about the project,
f. exit
Main class invokes methods of various other classes as per the menu selected.
2. Play - This is the key class that implements the play loop starting
with computer (Code Maker) setting a code as per the difficulty level.
Then Play class allows user (Code Breaker) to guess the code set by
Computer in “n” chances, where “n” depends on the difficulty level.
Also, Play class allows computer to provide the feedback on each code guessed by the user. When user guesses the code correctly or runs out of the chances, game ends.
3. GameBoard - This class represnts that board used for playing the game.
It consists of a secret code generated by the computer and n (12 or 10) String objects to hold the guesses made by the user.
4. Code - This class represents Code object which consists of number of
positions and colored pegs in those positions.
5. Peg - This class represents colored pegs. Each Peg object contains
one color. It also has all the allowed colors based on the difficulty level and rejects any invalid characters entered by the user.
6. Feedback - This class represents Feedback object which contains the
feedback provided by Code Maker (computer) to the Code Breaker (user).
Feedback contains only two colors - Black and White. Black color indicates
that a colored peg is placed at the correct position. White color
indicates that a color is placed at a different position. Feedback helps the user to decide his next guess.
7. How to play - This class displays the rules and information about
how to play the game.
8. DifficultyLevel - This class allows user to set difficulty level to oneof the four levels - Rookie, Pro, Expert and Genius. Play object determines number of guesses, number of positions and number of colors based on the difficulty level.
9. About - This class provides the details about the project developer,
version number, copyright, etc.
10. Fill - Displays Logo and "Loading" message.
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published