An open API service indexing awesome lists of open source software.

https://github.com/itsmenicky/guess-the-number

A guess the number game developed in Java
https://github.com/itsmenicky/guess-the-number

console-game java

Last synced: about 1 year ago
JSON representation

A guess the number game developed in Java

Awesome Lists containing this project

README

          

Guess The Number 🤔☕

It is necessary for the algorithm to generate a random number to be guessed by the user. To do this, I used the random library, generating a random number between 0 and 100 and storing it in the generator generator.

In the main class, a screen introducing the user to the game was implemented, followed by a while loop, with the purpose of asking the user for a number again whenever the number is different from the number generated by the program. If the user gets the number right, a victory message is shown on the console and the choice to play again, if the user chooses 's' a new number is generated and the loop is repeated, if 'n' the program is terminated.

To assist the user in discovering the number, the game checks the number entered by the user and compares it with the generated number, in order to give a hint whether it is larger or smaller. Thinking that the user will make several guesses and the game can restart several times, the clearConsole function was also implemented, which clears the console screen when called during the program execution.