Überprüfungen Kürzel und Name - Abfragen im Code enthalten
This commit is contained in:
parent
ac3b2908f3
commit
0b45380f15
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -654,6 +654,8 @@ public class HappyBirdMain extends Application {
|
||||
* Startet Spiel nach Namenseingabe
|
||||
*/
|
||||
public void startGameButtonClick() {
|
||||
if (correctName() && correctAcronym())
|
||||
{
|
||||
generateGameScreen();
|
||||
|
||||
/*Klick auf den Pause-Button, um das Pause-Menü aufzurufen*/
|
||||
@ -671,6 +673,10 @@ public class HappyBirdMain extends Application {
|
||||
gameRunning = !gameRunning;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
System.out.println("Name oder Kürzel falsch!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
@ -837,8 +843,8 @@ public class HappyBirdMain extends Application {
|
||||
*/
|
||||
public void writeIntoDatabase(int points)
|
||||
{
|
||||
String playername = nameLabel.getText();
|
||||
String playeracronym = acronymLabel.getText();
|
||||
String playername = name.getText();
|
||||
String playeracronym = acronym.getText();
|
||||
/*String sql = "INSERT INTO happybirddb(name, kuerzel, punkte) VALUES ('" + playername + "', '" + points +
|
||||
"', '" + playeracronym + "');";*/
|
||||
String sql = "INSERT INTO happybirddb (name, kuerzel, punkte) VALUES (?, ?, ?);";
|
||||
@ -862,13 +868,23 @@ public class HappyBirdMain extends Application {
|
||||
*/
|
||||
public boolean correctName()
|
||||
{
|
||||
String name = nameLabel.getText();
|
||||
if (!name.matches("[a-zA-ZÄÖÜäöüß ]*"))
|
||||
String nametext = name.getText();
|
||||
if (!nametext.matches("[a-zA-ZÄÖÜäöüß ]*"))
|
||||
{
|
||||
System.out.println("Fehler Schreibweise Name");
|
||||
return false;
|
||||
}
|
||||
if (name.charAt(0) < 'A' || name.charAt(0) > 'Z')
|
||||
if (nametext.length() > 0)
|
||||
{
|
||||
if (nametext.charAt(0) < 'A' || nametext.charAt(0) > 'Z')
|
||||
{
|
||||
System.out.println("Fehler Schreibweise Name 1. Buchstabe");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Name leer");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -881,13 +897,17 @@ public class HappyBirdMain extends Application {
|
||||
*/
|
||||
public boolean correctAcronym()
|
||||
{
|
||||
String acronym = acronymLabel.getText();
|
||||
if (acronym.length() < 3 || acronym.length() > 10)
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
if (!acronym.matches("[A-Za-z0-9]*"))
|
||||
if (!acronymtext.matches("[A-Za-z0-9]*"))
|
||||
{
|
||||
System.out.println("Fehler Schreibweise Kürzel");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user