-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHangmanUserInterface.java
51 lines (43 loc) · 1.58 KB
/
HangmanUserInterface.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import hangman.Hangman;
import java.util.Scanner;
public class HangmanUserInteface {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
Hangman hangman = new Hangman();
System.out.println("***********");
System.out.println("* HANGMAN *");
System.out.println("***********");
System.out.println("");
printMenu();
System.out.println("");
// PROGRAM YOUR SOLUTION HERE
while (hangman.gameOn()){
System.out.println("Type a command: ");
String command = reader.nextLine();
if (command.equals("quit")) {
break;
} else if (command.equals("status")){
//hangman.printMan();
//hangman.printWord();
hangman.printStatus();
} else if (command.length() == 1){
hangman.guess(command);
//hangman.printMan();
//hangman.printWord();
} else if (command.isEmpty()){
printMenu();
System.out.println("");
}
hangman.printMan();
hangman.printWord();
}
System.out.println("Thank you for playing!");
}
public static void printMenu() {
System.out.println(" * menu *");
System.out.println("quit - quits the game");
System.out.println("status - prints the game status");
System.out.println("a single letter uses the letter as a guess");
System.out.println("an empty line prints this menu");
}
}