-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutput.java
More file actions
25 lines (23 loc) · 1.12 KB
/
Output.java
File metadata and controls
25 lines (23 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public class Output extends Handler {
public void displayWelcome() {
// Displays a welcome message.
System.out.println("Welcome!");
System.out.println("Hangman is a word-guessing game, where you're given a set number of chances to identify an unknown word");
}
// Displays the current state of the game, including the
// partially-identified word and the number of remaining attempts.
public void displayGameState(GameState gameState) {
System.out.println("\nCurrent State: " + gameState.getDisplayedWord());
System.out.println("Remaining Attempts: " + gameState.getRemainingAttempts());
}
// Displays the final result of the game, which depends on whether the user won or lost the game.
public void displayResult(boolean hasWon, GameState gameState) {
if (hasWon) {
System.out.println("\nWord identified: " + gameState.getDisplayedWord());
System.out.println("Well done - you won!");
} else {
System.out.println("\nUh oh - you're out of attempts");
System.out.println("Game over, you lost!");
}
}
}