Question
Assignment Scope For this assignment the goal is to simulate the foundation of the components of the game MasterMind by creating a Codemaker, Codebreaker, and
Assignment Scope
For this assignment the goal is to simulate the foundation of the components of the game MasterMind by creating a Codemaker, Codebreaker, and the Game; this includes:
Set up constants, which are used for clarity, safety and consistency throughout a project.
Establish the method signatures (i.e. methods that must be implemented in the classes) for the interfaces ICodemaker, ICodebreaker, and IGame.
Establish the member variables for the classes to replicate the real game, write custom constructors, generate getters/setters for the member variables, instantiate instances of classes, write a simple method to randomly generate the secret code in the Codemaker class.
To accomplish this, write the follow source code:
Create constants using public static final
Using Java API classes Arrays, ArrayList, Color, HashSet, Random and Set
Update the interfaces to include method signatures
Updating the classes to include
Member variables
Getters/setters for member variables
i.
Right click in the source code file
Select RefactorEncapsulate Fields
Click on Select All button (on the right)
Click on Refactor button (on the bottom)
Custom constructor
Methods
Implementing interface methods
Instance variables
Import necessary classes
i.
Right click in the source code file
Select Fix Imports
Compress a project and submit to Webcourses
Decompress compressed project and verify it is a Netbeans project
References
Netbeans.docx
Setting up a project in Netbeans.docx
Netbeans right click menu help.docx
Deliverables
To complete this assignment you must submit your compressed Netbeans project to Webcourses.
Please keep in mind that the tasks are guidance to accomplish the goals of the assignment. At times students will be required to do additional research (e.g. Google That S*** (GTS)!) to find implementation options. In the industry, software engineers are expected to be very self-sufficient to find the best solution for the task at hand.
Tasks and Rubric
Activity | |
MasterMind project | |
MasterMind class | Method main() should: Instantiate an instance of class Game |
Constants | |
Constants class | Create constants by declaring them as public static final: public static final ArrayList codeColors = new ArrayList(Arrays.asList(Color.BLUE, Color.BLACK, Color.ORANGE, Color.WHITE, Color.YELLOW, Color.RED, Color.GREEN, Color.PINK)); ArrayList responseColors = new ArrayList(Arrays.asList(Color.RED, Color.WHITE)); int MAX_ATTEMPTS = 10; int MAX_PEGS = 4; int COLORS = 8; |
core package | |
Codebreaker class | Member variables ArrayList codebreakerAttempt Getter/setter for member variables Custom constructorEmpty parameter list Instantiates the member variable Implements ICodebreaker interface methodpublic void checkCode(ArrayList attempt) |
Codemaker class | Member variables Set secretCode ArrayList codemakerResponse Getter/setter for member variables Custom constructorEmpty parameter list Instantiates the member variables i.Member variable secretCode should be instantiated as an instance of class HashSet() ii.Member variable codemakerResponse should be instantiated as an instance of class ArrayList() Calls method generateSecretCode() Implements ICodemaker interface methodspublic void generateSecretCode() public void checkAttemptedCode() Method generateSecretCode() a.Instantiate and instance of Java API class Random b.Loop until four of the eight colors have been randomly selected to be the secret code with no duplicates (hint: member variable secretCode is of type Set which automatically does not allow for duplicates) i.Use the method .nextInt() in class Random to select an index into the Constants.codeColors ArrayList, pass the ArrayList as an argument to the method call ii.Create an instance of Java API class Color and set it equal to the color stored at the index of the Constants.codeColors ArrayList by calling the get() method in class ArrayList passing the int from step i. above as an argument iii.Add the selected color to the Set member variable by calling method .add in class Set passing the Color object from step ii. above as and argument c.Use an enhanced for loop to output the generated secret code |
Game class | Member variables int attempt Codebreaker codebreaker Codemaker codemaker Getter/setter for member variables Custom constructorEmpty parameter list Instantiates the member variables Implements IGame interface methods a.public void play() |
ICodebreaker interface | Add method signatures public void checkCode(ArrayList attempt) |
ICodemaker interface | Add method signatures public void generateSecretCode() public void checkAttemptedCode() |
IGame interface | Add method signatures public void play() |
userInterface package | |
MasterMindUi class | |
MasterMind application | |
Test Case 1 | Test Case 1 passes |
Source compiles with no errors | |
Source runs with no errors | |
Source includes comments |
Perform the following test cases
Test Cases | ||
Action | Expected outcome | |
Test Case 1 | Run application | The console window should be similar to figure 1 Java does NOT automatically translate its Color objects to a String value, rather it prints the RGB code of the color. |
Output:
Welcome to MasterMind! generated the secret code! java . awt . Color [r=255, g=175,b=175] java . awt Color [r=0, g=0,b=255] java.airt.color [r=2 55, g=, b#0] BUILD SUCCESSFUL (total time: 2 seconds)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started