Ü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,23 +654,29 @@ public class HappyBirdMain extends Application {
|
|||||||
* Startet Spiel nach Namenseingabe
|
* Startet Spiel nach Namenseingabe
|
||||||
*/
|
*/
|
||||||
public void startGameButtonClick() {
|
public void startGameButtonClick() {
|
||||||
generateGameScreen();
|
if (correctName() && correctAcronym())
|
||||||
|
{
|
||||||
|
generateGameScreen();
|
||||||
|
|
||||||
/*Klick auf den Pause-Button, um das Pause-Menü aufzurufen*/
|
/*Klick auf den Pause-Button, um das Pause-Menü aufzurufen*/
|
||||||
pauseButton.setOnAction(event -> {
|
pauseButton.setOnAction(event -> {
|
||||||
if(!menuScreenRunning) {
|
if(!menuScreenRunning) {
|
||||||
pauseButtonClick(gameRunning);
|
pauseButtonClick(gameRunning);
|
||||||
gameRunning = !gameRunning;
|
gameRunning = !gameRunning;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*ESC-Tast drücken, um das Pause-Menü aufzurufen*/
|
||||||
|
scene.setOnKeyPressed(e -> {
|
||||||
|
if(e.getCode() == KeyCode.ESCAPE && !menuScreenRunning) {
|
||||||
|
pauseButtonClick(gameRunning);
|
||||||
|
gameRunning = !gameRunning;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
System.out.println("Name oder Kürzel falsch!");
|
||||||
|
}
|
||||||
|
|
||||||
/*ESC-Tast drücken, um das Pause-Menü aufzurufen*/
|
|
||||||
scene.setOnKeyPressed(e -> {
|
|
||||||
if(e.getCode() == KeyCode.ESCAPE && !menuScreenRunning) {
|
|
||||||
pauseButtonClick(gameRunning);
|
|
||||||
gameRunning = !gameRunning;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@ -837,8 +843,8 @@ public class HappyBirdMain extends Application {
|
|||||||
*/
|
*/
|
||||||
public void writeIntoDatabase(int points)
|
public void writeIntoDatabase(int points)
|
||||||
{
|
{
|
||||||
String playername = nameLabel.getText();
|
String playername = name.getText();
|
||||||
String playeracronym = acronymLabel.getText();
|
String playeracronym = acronym.getText();
|
||||||
/*String sql = "INSERT INTO happybirddb(name, kuerzel, punkte) VALUES ('" + playername + "', '" + points +
|
/*String sql = "INSERT INTO happybirddb(name, kuerzel, punkte) VALUES ('" + playername + "', '" + points +
|
||||||
"', '" + playeracronym + "');";*/
|
"', '" + playeracronym + "');";*/
|
||||||
String sql = "INSERT INTO happybirddb (name, kuerzel, punkte) VALUES (?, ?, ?);";
|
String sql = "INSERT INTO happybirddb (name, kuerzel, punkte) VALUES (?, ?, ?);";
|
||||||
@ -862,13 +868,23 @@ public class HappyBirdMain extends Application {
|
|||||||
*/
|
*/
|
||||||
public boolean correctName()
|
public boolean correctName()
|
||||||
{
|
{
|
||||||
String name = nameLabel.getText();
|
String nametext = name.getText();
|
||||||
if (!name.matches("[a-zA-ZÄÖÜäöüß ]*"))
|
if (!nametext.matches("[a-zA-ZÄÖÜäöüß ]*"))
|
||||||
{
|
{
|
||||||
|
System.out.println("Fehler Schreibweise Name");
|
||||||
return false;
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -881,13 +897,17 @@ public class HappyBirdMain extends Application {
|
|||||||
*/
|
*/
|
||||||
public boolean correctAcronym()
|
public boolean correctAcronym()
|
||||||
{
|
{
|
||||||
String acronym = acronymLabel.getText();
|
String acronymtext = acronym.getText();
|
||||||
if (acronym.length() < 3 || acronym.length() > 10)
|
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;
|
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 false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user