-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGame.java
More file actions
39 lines (27 loc) · 976 Bytes
/
Copy pathGame.java
File metadata and controls
39 lines (27 loc) · 976 Bytes
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
package treehouse.hangman;
public class Game {
private String answer;
private String hits;
private String misses;
//THIS IS A COMMENT ADDED FROM GITHUB
//This class will hold the LOGIC for the hangman game
//THIS IS A COMMENT FROM SUBLIME TEXT ON 11/11/2017 AT 18:09PM
public Game(String answer) {
//I should have the answer, it should be PRIVATE
this.answer = answer;
hits = "";
misses = "";
//I should keep track of hits and misses
//I need to test if the letter guessed is in the answer
}
public boolean applyGuess(char letter) {
boolean isHit = ((answer.indexOf(letter) != -1) ? true : false);
System.out.print("the isHit returned " + isHit);
if (answer.indexOf(letter) == -1) {
misses += letter;
} else {
hits += letter;
}
return answer.indexOf(letter) != -1;
}
}