Number Guessing Game using Java 🎮

August 4, 2022

This is simple game
The game contains 5 players. One Umpire, one Guesser and three Players.
The guesser guesses a number between 1 and 10 and tell it to the umpire secretly. The remaining 3 players try to predict the number guessed by the guesser.
The one who predicts the number accurately is the winner of the game.
If more than one Player predicts the right number, all of them are winners.

Class Diagram for the game:

Image description

The guessing game involves an ‘Umpire’ object , ‘Guesser’ object and three ‘player’ objects. All the objects are created by instantiating the above 3 classes.

Features Included in this game:

⇒ Restricted the all the players and guesser to guess a number between 1 and 10. Even if they predict/guess a number out of this range, then the program will prompt to re-enter the input until they’re choosing a value with in allowed range.

Image description

Image description

⇒ added a counter to print player numbers in the console.

⇒ Print summary of the game after finding the winner. The summary includes Accuracy of prediction of players who lost the game.
Accuracy is displayed in terms of, how close number predicted by players towards the number guesser by guesser.

Image description

🖥The source code of the game is uploaded on GitHub:

🌎Connect with me on LinkedIn :

Source link

Comments 0

Leave a Reply

Your email address will not be published. Required fields are marked *