3. • The main menu has three options
• New Game – Starts a new game
• Rules – Shows instructions on how to
play the game
• Quit – Closes the application
• This is the page where the user goes if he
clicks “Main Menu” button which is available
on the game board
4. • Number is disabled when
clicked to have a code with
non repeating digits
• Enter will be enabled when
all for digits in the code are
ready to be entered
7. Controller
• The Controller is responsible for the flow of the data transmission
• It consists of the „main‟ method which is responsible for starting the game
• It is responsible for creating the View classes and Model classes
• It maintains instances of the Model classes and invokes various business methods in them;
in response to user‟s actions which could be either inputting the data or controlling the
Graphical User Interface (GUI) for displaying the data using View classes
View
• View classes handle the GUI for the user
• The data to be represented will be received from Controller whenever the user inputs new
information or performs specific actions.
• The received data from Controller will be presented in different elements such as
Textbox, Label, Button, Table etc. (Some of these widgets can accept input from the user)
• The View is independent from the Model classes; thus, it does not maintain any information
about the existing classes in the Model.
8. Model
• The Model is the main component and the heart of the application
• It has classes that will perform majority of the game functionality part
• The contained objects will have different business methods which are related to different business
events and scenarios that take place in the context of the application
• The master class is the Game class which is a concrete class that will keep track of the player’s turn
and the outcome of the game
9. • Display and Processing are separated
• Future enhancements and other maintenance of the code base made very easy and reusable
• Attach multiple views to a model to provide different presentations (view/model decoupling)
• Change the way a view responds to user input without changing its visual presentation”
(view/controller decoupling)
• All this combined gives GREAT FLEXIBILITY
15. • Used to have flexibility and maintainability
• We can increase the difficulty level in the future by adding concrete classes that use a better version
of the algorithm for guessing
• New checker functionality can be added when we decide to have a different method of checking for
feedback (Eg: Giving only feedback when the position as well as the number match and not for
number only)
16. • The controller component handles the entire application and the game starts by running the main
method in the controller component(singleton pattern)
• Only instance of the controller should be used to handle the game application
• Using a singleton pattern to control the creation of Controller class instances helps us in this case
17.
18.
19.
20. • The algorithm used to play the computer‟s chance is based on the famous five-guess
algorithm which was developed by Donald Knuth in 1977. The steps involved in
guessing a code given by the user is as follows:
1. Create a set S of remaining possibilities (Which is initially 10*9*8*7). Select the first
possibility from this set and use it as the first guess and get the feedback for this
guess
2. Remove all possibilities from S that would not give the same score of black and
white pegs in the feedback if they were the answer
3. Select the first possible code from S and use it as the next guess and get the
feedback.
4. Go back to step 2 until you have got it right
This is the only algorithm being used right
now but we can add various difficulty levels,
as we are using strategy pattern to implement
the algorithm.