-
Notifications
You must be signed in to change notification settings - Fork 0
/
HangmanIO.java
33 lines (27 loc) · 974 Bytes
/
HangmanIO.java
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
26
27
28
29
30
31
32
33
import java.util.*;
public class HangmanIO{
//Ask for user input
public char userInput(){
Scanner input = new Scanner(System.in);
char letter = ' ';
System.out.println("Guess a letter: ");
letter = input.nextLine().charAt(0); //store only first letter from the user input
return letter;
}
//ask user if wants to play again
public char again(char cont){
Scanner input = new Scanner(System.in);
System.out.println("Try again? (Y/y)");
cont = input.nextLine().charAt(0);
return cont;
}
//prints game over message and the guessing word
public void gameOver(String guessingWord){
System.out.println("Game Over!");
System.out.println("The word is " + guessingWord + ".");
}
//prints output for winning the game
public void correct(){
System.out.println("You won!");
}
}