2022-11-24 13:59:26 +01:00
|
|
|
import java.util.ArrayList;
|
2022-11-29 16:20:48 +01:00
|
|
|
import java.util.Scanner;
|
2022-11-24 13:59:26 +01:00
|
|
|
|
2022-11-29 16:20:48 +01:00
|
|
|
/**
|
2022-12-14 13:17:46 +01:00
|
|
|
* The class Execute is the execution file for the whole program.
|
2022-11-24 13:59:26 +01:00
|
|
|
*/
|
|
|
|
public class Execute {
|
2022-11-29 16:20:48 +01:00
|
|
|
public static void main(String[] args) {
|
2022-12-07 12:02:02 +01:00
|
|
|
Data datei = new Data("users.txt");
|
2022-12-14 20:53:16 +01:00
|
|
|
ArrayList<User> user = datei.readUser();
|
2022-11-29 16:18:32 +01:00
|
|
|
|
2022-11-29 16:20:48 +01:00
|
|
|
for (User user1 : user) {
|
|
|
|
System.out.println(user1);
|
|
|
|
}
|
|
|
|
System.out.println();
|
|
|
|
System.out.println("\t\t\tANMELDUNG");
|
|
|
|
int i = 0;
|
|
|
|
Scanner leser = new Scanner(System.in);
|
2022-12-07 12:02:02 +01:00
|
|
|
|
2022-11-29 16:20:48 +01:00
|
|
|
while (true) {
|
|
|
|
|
|
|
|
|
|
|
|
System.out.print("Name: ");
|
|
|
|
boolean error = false;
|
|
|
|
String name = leser.nextLine();
|
2022-12-07 12:02:02 +01:00
|
|
|
error = isError(error, name);
|
2022-11-29 16:20:48 +01:00
|
|
|
System.out.print("Passwort: ");
|
|
|
|
String password = leser.nextLine();
|
2022-12-07 12:02:02 +01:00
|
|
|
error = isError(error, password);
|
2022-11-29 16:20:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
for (User user1 : user) {
|
|
|
|
if (!error) {
|
|
|
|
if (user1.getPassword().equals(password) && user1.getPhonenumber().equals(name)) {
|
|
|
|
System.out.println();
|
|
|
|
System.out.println("Herzlich Willkommen " + user1.getNameParent1() + " und " + user1.getNameParent2() + ", Ihr Login war erfolgreich!");
|
|
|
|
i++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
} else if (!(user1.getPassword().equals(password) && user1.getPhonenumber().equals(name))) {
|
|
|
|
System.out.println("Login fehlgeschlagen. Versuchen Sie es erneut.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
System.out.println("Bitte Anmeldedaten angeben.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i > 0) {
|
|
|
|
break;
|
|
|
|
}
|
2022-11-24 13:59:26 +01:00
|
|
|
}
|
|
|
|
}
|
2022-12-07 12:02:02 +01:00
|
|
|
|
|
|
|
private static boolean isError(boolean error, String name) {
|
|
|
|
if (name.isEmpty()) {
|
|
|
|
error = true;
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
2022-11-24 13:59:26 +01:00
|
|
|
}
|