|
|
|
@ -33,7 +33,7 @@ public class Hangman extends Application { |
|
|
|
resetButton.setDefaultButton(true); |
|
|
|
resetButton.relocate(25,350); |
|
|
|
main.getChildren().add(resetButton); |
|
|
|
|
|
|
|
|
|
|
|
resetButton.setOnAction( |
|
|
|
e -> { |
|
|
|
Pane newPane = setUpLayout(statusBox); |
|
|
|
@ -64,7 +64,7 @@ public class Hangman extends Application { |
|
|
|
|
|
|
|
//set new word to guess |
|
|
|
this.secretWord = dict.getRandomWord(); |
|
|
|
System.out.println(this.secretWord); |
|
|
|
//System.out.println(this.secretWord); |
|
|
|
GridPane word = new GridPane(); |
|
|
|
word.setHgap(5); |
|
|
|
|
|
|
|
@ -206,11 +206,21 @@ public class Hangman extends Application { |
|
|
|
return inSecretWord;// && !guessed; |
|
|
|
} |
|
|
|
private void checkIfWon(String s, Text statusBox) { |
|
|
|
int i = 0; |
|
|
|
char let = s.charAt(0); |
|
|
|
for (i = 0; i < this.lettersRevealedSoFar.length; i ++) { |
|
|
|
if (this.secretWord.charAt(i) == let) { |
|
|
|
this.lettersRevealedSoFar[i].setText(s); |
|
|
|
} |
|
|
|
} |
|
|
|
//write your code here |
|
|
|
boolean won = true; |
|
|
|
int i = 0; |
|
|
|
i = 0; |
|
|
|
String letter; |
|
|
|
while (won && i < this.lettersRevealedSoFar.length) { |
|
|
|
won = lettersRevealedSoFar[i].getText() != "_"; |
|
|
|
letter = lettersRevealedSoFar[i].getText(); |
|
|
|
won = letter != "_"; |
|
|
|
//System.out.println("\"" + letter + "\"" + "," + won); |
|
|
|
i += 1; |
|
|
|
} |
|
|
|
if (won) { |
|
|
|
|