Bulls and Cows is a guessing game where you try to guess an 'n' digit code. (Note: each number in the code must be distinct) When a number is guessed and a digit is in the correct location, then that...

Bulls and Cows is a guessing game where you try to guess an 'n' digit code. (Note: each number in the code must be distinct) When a number is guessed and a digit is in the correct location, then that is a bull. When a digit is in the number, but in the incorrect location, then that is a cow. So if a 3 digit code is 289, and the user guesses 829. Then that is "1 bull and 2 cows" because '9' is in the correct location and '2' and '8' are in the code but are currently in the wrong location. The guessing continues until the code is guessed in the correct order... "3 bulls"! This website will give you a feel for the game. To emulate our version using 3 digits, click on "Options" and select any 0-9, 3 Codes. http://www.mathsisfun.com/games/bulls-and-cows.html Note: Programming Project should be done primarily on your own. However, it is appropriate to get some support from your professor, and even other students. Refer to the Syllabus for guidelines. Remember to use Piazza and post your partial code if you are stuck with a problem in your code Requirements Use appropriate static methods to separate basic functionality of the implementation. For example: checkBulls0, checkCows) etc Ask from the user to provide the option (3 digits, 4 digits or 5 digits code). Then use the provided generateRandomCode0 method to generate a random code. The code must be stored in a String Get guess from user as a String If more digits than the number in the code, get number again. For example: the code is 3 digit (145) but user enters 5 digit guess (5687) If any digits are repeated, get number again For example: If the user guess is 335, get the number again If not enough digits, assume the missing digit to the left as zero For example: For a 3 digit code, 35 is the same as 035 where zero is the first digit. On the other hand, if user enters 5 for a 3 digit code, then you need to reject this entry because 005 is a repeating code If the user enters string "quit" anytime during the play, the program should stop and display the code that the user was playing with output "Thanks for playing!" You must allow the program to be played repeatedly without ending the program after successful run (that is getting all the bulls). . Typing 'y' causes program to run again. Anything else exits the program with output Thanks for playing!
May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here