From f82b847a7bcbfc936f3ad4efaca8ecce19b6cae8 Mon Sep 17 00:00:00 2001 From: blues Date: Wed, 5 Aug 2020 15:29:01 +0200 Subject: [PATCH] 05.08.2020 --- HangmanFx/src/application/Main.java | 21 ++++++++++----------- HangmanFx/src/application/Ui.fxml | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/HangmanFx/src/application/Main.java b/HangmanFx/src/application/Main.java index c445adf..2f5c6bb 100644 --- a/HangmanFx/src/application/Main.java +++ b/HangmanFx/src/application/Main.java @@ -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"); diff --git a/HangmanFx/src/application/Ui.fxml b/HangmanFx/src/application/Ui.fxml index 615b3e7..2fe147f 100644 --- a/HangmanFx/src/application/Ui.fxml +++ b/HangmanFx/src/application/Ui.fxml @@ -30,7 +30,7 @@ - +