-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHangman.java
41 lines (27 loc) · 979 Bytes
/
Hangman.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
import java.util.ArrayList;
class Hangman {
public static void main(String[] args) {
Printer printer = new Printer();
printer.printTitle();
WordParser wordparser = new WordParser("./wordlist.txt");
wordparser.createFile();
wordparser.createScanner();
ArrayList<String> words = wordparser.parse();
// Print word for testing
// System.out.println(word);
printer.printEmptyLine();
int winningStreak = 0;
do {
WordPicker wordPicker = new WordPicker(words);
String word = wordPicker.pick();
Game game = new Game(word);
if (game.play() == true) {
winningStreak += 1;
printer.print("Winning streak: " + winningStreak);
} else {
winningStreak = 0;
}
} while (PlayAgain.wannaPlay() == true);
printer.print("Thanks for playing!");
}
}