Question: java please In each round, the player makes a guess and and the system tells the player how many pegs of the guess were exact

 java please In each round, the player makes a guess andand the system tells the player how many pegs of the guesswere exact matches to the code (correct in both color and position,

java please

In each round, the player makes a guess and and the system tells the player how many pegs of the guess were exact matches to the code (correct in both color and position, marked 'x'), and how many colours were partial matches to the code (correct color placed in the wrong position, marked 'o'). The feedback is displayed in a 2x2 grid format similar to the board game. e.g. suppose the code is black red blue green Guess #1: blue red green yellow The feedback shows that there is one exact match and 2 partial matches. Notice that this configuration does not indicate which pegs are exact matches. The player makes guesses until a) the player breaks the code (player wins!) or b) 10 guesses are made but did not result in a full match (system wins). a. 1. Create the generic ArrayList class that implements the List interface (note that List extends Iterable) Overload the add method: include another add method that will have one parameter: an element that adds to the end of the list. b. Override the equals method that checks if the ArrayList is equivalent to the given instance. C. Make your ArrayList dynamic: the array should grow if it runs out of space and shrink if it is less than half full. Modify your add and remove methods and include a resize method to support the dynamic structure. Set the default capacity to 4. 2. Create a class named Peg with field colour. Include any other fields/methods to help with gameplay. Override the equals() method to return true if the colours match. 3. Write a Game class that acts as the code maker and handles the mechanics of the Mastermind game. Include a minimal main method that instantiates the game and invokes gameplay. Your program should have the following: a. An instance of ArrayList that holds a set of 4 pegs of which colours are randomly generated. Each peg has a colour of 6 different possibilities (duplicates are allowed, blanks are not). b. Another ArrayList that holds pegs that represent the player's guess C. A game loop that prompts the user for their guess and determines if the 2 ArrayLists are equal: i. if so, notify the player and end the game ii. If not, provide the user feedback on their guess: Determine whether if each peg of the guess is a match, and mark it accordingly - You will need to compare the guess against the code, and determine the number of exact and partial matches. f. After their 10th guess, if it is not a full match, inform the player that the system won. Suggestions: - Display the generated code for testing (and remove before submitting) For guess feedback: must be careful to avoid counting any of the pegs twice; make at least two passes to compare the guess and the code. In the first pass, look for exact matches and in the second pass, look for partial matches. Notes: - You may assume that the player input is valid i.e. if it is an invalid colour, the player loses and the game is over. Enums are optional (colour, match status) (code: white blue yellow green] System: Player: Guess #1: blue blue blue blue System: Guess #2: blue red red red Player: System: - O Guess #3: yellow blue yellow yellow Player: System: 1 Guess #4: green blue yellow green Player: System: Guess #5: green blue yellow black Player: System: X X 0 Player: System: Guess #6: white blue yellow green You cracked the code! In each round, the player makes a guess and and the system tells the player how many pegs of the guess were exact matches to the code (correct in both color and position, marked 'x'), and how many colours were partial matches to the code (correct color placed in the wrong position, marked 'o'). The feedback is displayed in a 2x2 grid format similar to the board game. e.g. suppose the code is black red blue green Guess #1: blue red green yellow The feedback shows that there is one exact match and 2 partial matches. Notice that this configuration does not indicate which pegs are exact matches. The player makes guesses until a) the player breaks the code (player wins!) or b) 10 guesses are made but did not result in a full match (system wins). a. 1. Create the generic ArrayList class that implements the List interface (note that List extends Iterable) Overload the add method: include another add method that will have one parameter: an element that adds to the end of the list. b. Override the equals method that checks if the ArrayList is equivalent to the given instance. C. Make your ArrayList dynamic: the array should grow if it runs out of space and shrink if it is less than half full. Modify your add and remove methods and include a resize method to support the dynamic structure. Set the default capacity to 4. 2. Create a class named Peg with field colour. Include any other fields/methods to help with gameplay. Override the equals() method to return true if the colours match. 3. Write a Game class that acts as the code maker and handles the mechanics of the Mastermind game. Include a minimal main method that instantiates the game and invokes gameplay. Your program should have the following: a. An instance of ArrayList that holds a set of 4 pegs of which colours are randomly generated. Each peg has a colour of 6 different possibilities (duplicates are allowed, blanks are not). b. Another ArrayList that holds pegs that represent the player's guess C. A game loop that prompts the user for their guess and determines if the 2 ArrayLists are equal: i. if so, notify the player and end the game ii. If not, provide the user feedback on their guess: Determine whether if each peg of the guess is a match, and mark it accordingly - You will need to compare the guess against the code, and determine the number of exact and partial matches. f. After their 10th guess, if it is not a full match, inform the player that the system won. Suggestions: - Display the generated code for testing (and remove before submitting) For guess feedback: must be careful to avoid counting any of the pegs twice; make at least two passes to compare the guess and the code. In the first pass, look for exact matches and in the second pass, look for partial matches. Notes: - You may assume that the player input is valid i.e. if it is an invalid colour, the player loses and the game is over. Enums are optional (colour, match status) (code: white blue yellow green] System: Player: Guess #1: blue blue blue blue System: Guess #2: blue red red red Player: System: - O Guess #3: yellow blue yellow yellow Player: System: 1 Guess #4: green blue yellow green Player: System: Guess #5: green blue yellow black Player: System: X X 0 Player: System: Guess #6: white blue yellow green You cracked the code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!