This is a simple console-based number guessing game implemented in Java, demonstrating basic OOP (Object-Oriented Programming) principles with separate classes for the Guessor, Players, and the Umpire.
The game follows a simple, structured process:
- The Guessor secretly inputs a number.
- Up to four Players then input their guesses.
- The Umpire collects all inputs and compares the players' guesses against the Guessor's number, announcing all winners.
The project is divided into four files to ensure high readability and maintain separation of concerns:
Class File | Responsibility |
---|---|
GuessorGame.java |
Contains the main method. Initializes the game and coordinates the process. |
Umpire.java |
Manages the game flow. Collects the numbers and performs the comparison logic. |
Guessor.java |
Handles the input for the secret number. |
Player.java |
Handles the input for a single player's guess. |
- Navigate to the project's source directory (the folder containing the
.java
files). - Compile all files:
javac *.java
- Execute the main class:
java GuessorGame
- Open the project in IntelliJ.
- Open the
GuessorGame.java
file. - Click the green run button next to the
main
method definition.