Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Individual Project Challenge 03 - Mastermind Design and write Java a program that allows a user to play the classic game of Mastermind. In this

image text in transcribedimage text in transcribedimage text in transcribed
Individual Project Challenge 03 - Mastermind Design and write Java a program that allows a user to play the classic game of Mastermind. In this game, the computer chooses a random 4 digit number that the player must guess. When the player makes a guess. the computer tells the user how many digits in their 4 digit guess match the digit in the same position in the randomly daosen number. For example, if the computer chooses the random 4 digit number 1 442, and the user guesses 441 2, the computer will respond with the message "You matched 2". This is because two digits in the user's guess match the digits in the same positions in the computer's randome chosen number. Specically, the 2nd and 4th digits match. Here's an example interaction (user input in bold}: MASTERHIND - - - - Guess the 4 digit number! Guess 1: am You matched 6 Guess 2: 1111 You matched 1 Guess 3: 1234 You matched 1 Guess 4: 1444 You matched 3 Guess 4: 1442 You matched 4 Congratulations! You guessed the right mailer in 5 guesses. congratulations ! You guessed the right number 5 guesses would you like to play again ( y / n ) ? Part 1 - Implement the Mastermind Class In a file named Mastermind java implement the class d escribed by the UML Class Diagram below Mastermind secretNumber guesscount : int + Mastermind ( ) sedefault constructorss + pick Newsecret Number ( ) + makeGuess ( guess : int ) : int + getGuesscount ( ) : in generatesecretNumber ( ) : in getRandombig it ( ) : in The get Random Digit method should return a randomly chosen integer between O and 9 ( inclusive ) The generate Secret Number method should call the getRandom Digit method 4 times to get the 4 random digits of the new secret number . This method should return the 4 digit secret number as an in The pick New Secret Number method should call the generate SecretNumber method to get a new 4 digi isit secret number . This method should store the new secret number in the class level variable named secret Number and it should set the value of the class level variable named guess Count to O The default constructor method should call the pick New SecretNumber method to initialize the game with a randomly chosen 4 digit secret number The make Guess method should compare the digits in the parameter variable ( the user's guess ) to to the digits in the secretNumber . ThisThe make Guess method should compare the digits in the parameter variable ( the user's guess ) to the digits in the secretNumber . This method should count the number of matching digits and return this number . This method should also increment the class level variable named guess Count by The get Guess Count method should return the value stored in the class level variable named guess Count Part 2 - Implement the main Program Logic In a file named Main java , implement a main method that meets the requirements detailed below . You should include any other code in this fil that you feel is necessary Here is a pseudocode description of the algorithm you should implement in your main method create a Mastermind game object While the user want to play another game Pick a new secret number While the user's guess is not completely correct prompt the user to make a guess user enters a guess Display number of correct digits in users guess Congratulate the user and tell them the number of guesses they took Ask the user if they want to play again

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions