Question
Computer chooses: 3691
User guesses: 1649
Computer answers: 1 bull and 2 cows
If the user guesses a number with repeat digits that is partially correct the rule is that a correct digit can only count once and bulls count before cows. So for example
Computer chooses: 3691
User guesses: 4211
Computer answers: 1 bull and 0 cows
Your program should report the number of attempts the user needed to guess the number at the end of the game.
Your program should consist of two additional classes: Game and Oracle. All input and output should happen in the Game class. This is where you will ask the player for their guess and this is where you will tell the player how many bulls and cows they got. The Oracle class should store the actual computer choice as a String and have methods to determine how many bulls and cows any given guess would generate.
For aspiring hackers: Write a class that computerizes the human user and requires on average less than 8 turns to guess the pattern. Write a new test class and a Simulator class (the Simulator class will sub for the Game class) to demonstrate this ability by playing 1000 games of computer versus computerized user and reporting the average number of guesses.
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
public class Game{private int turns;
private Oracle computer;
private Scanner input;
// you may need more instance variables here
private int attempt;
private boolean gameover;
public Game(){
// your code for the Game constructor goes here
turns = 0;
computer = new Oracle();
input = new Scanner(System.in);
attempt = 0;
gameover = false;
}
public void playGame(){
// your code for the Game playGame method goes here
char c;
while (true) {
playOneTurn();
if (gameover) {...