MasterMind game is designed based on idea of MVC design pattern and is implemented on C++.
Here two classes CodePeg and KeyPeg which store data standing for Model. The class InputValidator stands for View and two classes CodePegCalculator and Configurator stand for Controller.
The controller will process data from View and store it in Model.
Algorithm for check the result that we check for WHITE condition first and then check for BLACK condition later.
After that, we combine both BLACK and WHITE condition to get final result.
For simple, there is no GUI designed but only command line interface instead.
Legend:
CodePeg: A ball that associated with a certain colour and position.
KeyPeg: A plate has 4 holes showing result (BLACK, WHITE, NONE) after player guessing.
Source code is written on Eclipse IDE (build with GCC Linux 64bit). So, Please import it to Eclipse if you would like to use Eclipse to view and run code.
In order to ensure win the game, you simply input only 1 color and then enter 11 12 13 14.
Below is class diagram for the program.
Download source code here or Github.
No comments:
Post a Comment