The aim of gue55ing game is for a person and the computer


The aim of Gue55ing Game is for a person and the computer to compete against other to correctly guess a hidden number. 

A game consists of four rounds. For each round a number between 1 and 100 (inclusive) is randomly generated and the players (person and computer) take turns to guess the number. The round ends when the correct guess is given or each player has had three guesses. 

If a player guesses the number correctly then they are awarded points according to how many attempts were taken to guess the number. If the round ends without either player guessing correctly then the points are awarded to each player according to how close they were to the hidden number. 

At the end of the four rounds the player with the highest cumulative score wins the game. 

Your program should consist of at least three classes: Player, Game and RandomNumber. 

Player class 

The Player class will specify the attributes and behaviours of a player. An object of the Player class will have the following fields (at least): 

Name - the name of the player. 

Score - the cumulative game score 

Guesses - the last number guessed for the current round 

The data type of each field must be chosen carefully and you must be able to justify the choice of the data type of the fields. You may want to include comments in the class to state the assumption made. The class must also have a default constructor and a non-default constructor that accepts a value for the name of the player. 

The Player class should also have appropriate accessor and mutator methods for its fields. You should not allow an object of class Player to be set to an invalid state. There should be no input from the terminal or output to the screen. A Player object should also be able to return its state in the form of a String. 

Game class 

The Game class will be in the same BlueJ project that contains your Player class. The Game class will manage the playing of a game. It will have the following fields (at least): 

Player1 (an object of type Player) 

Player2 (an object of type Player) 

Note that one of these players will be the computer. 

The Game class will have methods to manage the playing of the game. These should include (at least) the following behaviours: 

    • Display a welcome message on the screen.
  • Request the player to enter their name. 
  • Request the player to enter a number. 
  • Compare the number entered by a player with the hidden number. 
  • Display the result of the attempt at guessing the number. 
  • Display the result for the end of a round (including the value of the hidden number). 
  • Display the game result. 

RandomNumber class 

An object of the RandomNumber class will generate a random number from 1 to a maximum value specified.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: The aim of gue55ing game is for a person and the computer
Reference No:- TGS02731307

Now Priced at $30 (50% Discount)

Recommended (95%)

Rated (4.7/5)