-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHangman copy.java
executable file
·79 lines (56 loc) · 1.17 KB
/
Hangman copy.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* File: Hangman.java
* ------------------
* This program will eventually play the Hangman game from
* Assignment #4.
*/
import acm.graphics.*;
import acm.program.*;
import acm.util.*;
import java.awt.*;
import java.util.Random;
private HangmanLexicon lexicon;
private String word;
private int guessRemaining;
private String guessLetter;
public class Hangman extends ConsoleProgram {
public void run() {
/* You fill this in */
setupGame();
playGame();
}
private void setupGame() {
lexicon = new HangmanLexicon();
println("Welcome to Hangman!");
}
private playGame() {
getWord();
guessRemaining = Num_Guesses;
while (true) {
println("The word now looks like: " + workingString());
printNumGuesse();
String guessline = getGuesses();
if (guessline.equalIgnoreCase(word)){
printWinMsg();
break;
}
checkGuess(guessline);
if (guessRemaining == 0 | guessRemaining < 0) {
printLossMsg();
break;
}
}
}
private int getGuesses() {
}
private boolean checkGuess(String) {
}
private void getWord() {
//generate a random number
word
}
private void printWinMsg() {
}
private void printLossMsg() {
}
}