diff --git a/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.bin b/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.bin index cb54f61..6796b0d 100644 Binary files a/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.bin and b/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.bin differ diff --git a/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.lock b/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.lock index 6b4b29b..561aebf 100644 Binary files a/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.lock and b/Happy_Bird/.gradle/7.1.1/executionHistory/executionHistory.lock differ diff --git a/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.bin b/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.bin index 12b5000..57dd6dd 100644 Binary files a/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.bin and b/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.bin differ diff --git a/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.lock b/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.lock index fd2fc3f..e9817d4 100644 Binary files a/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.lock and b/Happy_Bird/.gradle/7.1.1/fileHashes/fileHashes.lock differ diff --git a/Happy_Bird/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/Happy_Bird/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 423f310..5e54e74 100644 Binary files a/Happy_Bird/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/Happy_Bird/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/Happy_Bird/build/classes/java/main/com/example/happy_bird/HappyBirdMain.class b/Happy_Bird/build/classes/java/main/com/example/happy_bird/HappyBirdMain.class index 95e93f9..16de531 100644 Binary files a/Happy_Bird/build/classes/java/main/com/example/happy_bird/HappyBirdMain.class and b/Happy_Bird/build/classes/java/main/com/example/happy_bird/HappyBirdMain.class differ diff --git a/Happy_Bird/build/libs/Happy_Bird-1.0-SNAPSHOT.jar b/Happy_Bird/build/libs/Happy_Bird-1.0-SNAPSHOT.jar index 515599e..3b00d83 100644 Binary files a/Happy_Bird/build/libs/Happy_Bird-1.0-SNAPSHOT.jar and b/Happy_Bird/build/libs/Happy_Bird-1.0-SNAPSHOT.jar differ diff --git a/Happy_Bird/build/tmp/compileJava/previous-compilation-data.bin b/Happy_Bird/build/tmp/compileJava/previous-compilation-data.bin index c9449f8..49124a6 100644 Binary files a/Happy_Bird/build/tmp/compileJava/previous-compilation-data.bin and b/Happy_Bird/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/Happy_Bird/src/main/java/com/example/happy_bird/HappyBirdMain.java b/Happy_Bird/src/main/java/com/example/happy_bird/HappyBirdMain.java index 289cf24..4fcafb2 100644 --- a/Happy_Bird/src/main/java/com/example/happy_bird/HappyBirdMain.java +++ b/Happy_Bird/src/main/java/com/example/happy_bird/HappyBirdMain.java @@ -55,9 +55,11 @@ public class HappyBirdMain extends Application { private final Label highscoreMenuLabel = new Label(); private final Label currentScoreEndscreenLabel = new Label("YOUR SCORE: "); private final Label endScreenHeadline = new Label("GAME OVER"); + private final Label checkNameLabel = new Label(""); + private final Label checkAcronymLabel = new Label(""); /*Labels in Arrays speichern*/ - private final Label[] labels = {nameLabel, acronymLabel, soundLabel, currentScoreLabel, highscoreLabel, highscoreMenuLabel}; + private final Label[] labels = {nameLabel, acronymLabel, soundLabel, currentScoreLabel, highscoreLabel, highscoreMenuLabel, checkAcronymLabel, checkNameLabel}; private final Label[] headlineLabels = {headline}; /*Buttons erstellen und zuweisen*/ @@ -501,6 +503,13 @@ public class HappyBirdMain extends Application { for(Button button : buttons) { button.setVisible(false); } + /*Label für Namenskonventionen*/ + checkNameLabel.setLayoutX(15); + checkNameLabel.setLayoutY(290); + + /*Label für Kürzelkonventionen*/ + checkAcronymLabel.setLayoutX(15); + checkAcronymLabel.setLayoutY(440); /*gebrauchte Buttons einblenden, ggf. anpassen*/ menuButton.setVisible(true); @@ -516,12 +525,15 @@ public class HappyBirdMain extends Application { for (Label label : labels ) { label.setVisible(true); } - + System.out.println(name.getLayoutY()); + System.out.println(acronym.getLayoutY()); /*nicht verwendete Labels ausblenden*/ highscoreLabel.setVisible(false); currentScoreLabel.setVisible(false); soundLabel.setVisible(false); highscoreMenuLabel.setVisible(false); + checkAcronymLabel.setVisible(false); + checkNameLabel.setVisible(false); /*Click-Events*/ startGameButton.setOnAction(event -> startGameButtonClick()); @@ -670,7 +682,7 @@ public class HappyBirdMain extends Application { * Startet Spiel nach Namenseingabe */ public void startGameButtonClick() { - if (correctName() && correctAcronym()) + if (correctName() == 0 && correctAcronym() == 0) { generateGameScreen(); System.out.println(gameRunning); @@ -704,6 +716,26 @@ public class HappyBirdMain extends Application { } }); + } else { + checkNameLabel.setVisible(false); + checkAcronymLabel.setVisible(false); + if (correctName() == 1) { + checkNameLabel.setText("nicht erlaubte Zeichen!"); + checkNameLabel.setVisible(true); + } else if (correctName() == 2) { + checkNameLabel.setText("1. Buchstabe muss groß!"); + checkNameLabel.setVisible(true); + } else if (correctName() == 3) { + checkNameLabel.setText("Name nicht leer!"); + checkNameLabel.setVisible(true); + } + if (correctAcronym() == 1) { + checkAcronymLabel.setText("nicht erlaubte Zeichen!"); + checkAcronymLabel.setVisible(true); + } else if (correctAcronym() == 2) { + checkAcronymLabel.setText("Länge 3-10 Zeichen!"); + checkAcronymLabel.setVisible(true); + } } } @@ -942,51 +974,56 @@ public class HappyBirdMain extends Application { * Überprüft, ob der eingegebene Name den Vorgaben entspricht * (Erlaubte Zeichen: Groß- und Kleinbuchstaben, Umlaute und Leerzeichen * - * @return true, wenn ja, sonst false + * @return 0, wenn ja, + * sonst: 1, wenn nicht erlaubte Zeichen verwendet + * 2, wenn der 1. Buchstabe kleingeschrieben ist + * 3, wenn der Name leer ist */ - public boolean correctName() { + public int correctName() { String nametext = name.getText(); if (!nametext.matches("[a-zA-ZÄÖÜäöüß ]*")) { System.out.println("Fehler Schreibweise Name - nicht erlaubte Zeichen"); - return false; + return 1; } if (nametext.length() > 0) { if (nametext.charAt(0) < 'A' || nametext.charAt(0) > 'Z') { System.out.println("Fehler Schreibweise Name - 1. Buchstabe muss großgeschrieben werden"); - return false; + return 2; } } else { System.out.println("Name darf nicht leer sein"); - return false; + return 3; } - return true; + return 0; } /*** * Überprüft, ob das eingegebene Akronym den Vorgaben entspricht * ( >= 3 Zeichen, <= 12 Zeichen, Groß- und Kleinbuchstaben, Zahlen 0-9 -- keine Sonderzeichen) - * @return true, wenn ja, sonst false + * @return 0, wenn ja, + * sonst: 1, wenn die Länge nicht korrekt ist + * 2, wenn nicht erlaubte Zeichen verwendet werden */ - public boolean correctAcronym() { + public int correctAcronym() { String acronymtext = acronym.getText(); System.out.println(acronymtext.length()); System.out.println(acronymtext); - if (acronymtext.length() < 3 || acronymtext.length() > 10) - { - System.out.println("Fehler Länge Kürzel (3-10 Zeichen)"); - return false; - } if (!acronymtext.matches("[A-Za-z0-9]*")) { System.out.println("Fehler Schreibweise Kürzel - nur Buchstaben und Zahlen erlaubt"); - return false; + return 1; } - return true; + if (acronymtext.length() < 3 || acronymtext.length() > 10) + { + System.out.println("Fehler Länge Kürzel (3-10 Zeichen)"); + return 2; + } + return 0; } /***