05.08.2020
This commit is contained in:
parent
229204b417
commit
f82b847a7b
|
@ -102,27 +102,26 @@ public class Main extends Application {
|
|||
}
|
||||
|
||||
// Check the letter from Textfield
|
||||
public boolean letterCheck(char[] wortToArr, char[] displayWord) {
|
||||
|
||||
for (int i = 0; i < wort.length(); i++) {
|
||||
if (letter.getText().isEmpty() == false) {
|
||||
if (wortToArr[i] == letter.getText().toLowerCase().charAt(0)
|
||||
public boolean arrayMatch(char[] wortToArr, char[] displayWord) {
|
||||
boolean result = false;
|
||||
if(!letter.getText().isEmpty()) {
|
||||
for (int i = 0; i < wortToArr.length; i++) {
|
||||
if(wortToArr[i] == letter.getText().toLowerCase().charAt(0)
|
||||
|| wortToArr[i] == letter.getText().toUpperCase().charAt(0)) {
|
||||
displayWord[i] = wortToArr[i];
|
||||
return true;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Confirm\check typed Letter
|
||||
public void checkLetter() {
|
||||
public void verifyTypedLetter() {
|
||||
info.setText("");
|
||||
|
||||
if (letterCheck(wortToArr, displayWord) == true) {
|
||||
if (arrayMatch(wortToArr, displayWord)) {
|
||||
rightletterString = new String(displayWord);
|
||||
hangmanWord.setText(rightletterString);
|
||||
info.setText("Richtig");
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<effect>
|
||||
<Bloom threshold="0.0" />
|
||||
</effect></ImageView>
|
||||
<TextField fx:id="letter" disable="true" layoutX="37.0" layoutY="298.0" onKeyReleased="#checkLetter" prefHeight="72.0" prefWidth="82.0" promptText="...">
|
||||
<TextField fx:id="letter" disable="true" layoutX="37.0" layoutY="298.0" onKeyReleased="#verifyTypedLetter" prefHeight="72.0" prefWidth="82.0" promptText="...">
|
||||
<font>
|
||||
<Font size="41.0" />
|
||||
</font>
|
||||
|
|
Loading…
Reference in New Issue
Block a user