Login aktualisiert!

This commit is contained in:
Kevin Pfannenstiel 2022-12-21 08:28:06 +01:00
parent 76d08d93da
commit de77901f5a
5 changed files with 44 additions and 92 deletions

Binary file not shown.

View File

@ -28,73 +28,28 @@ public class Execute {
System.out.println(""); System.out.println("");
System.out.println("____________________________LOGIN_______________________________"); System.out.println("____________________________LOGIN_______________________________");
System.out.println("");
System.out.println("Bitte einloggen");
Data userData = new Data("user.txt"); Data userData = new Data("user.txt");
Login login = new Login(); Login login = new Login();
Scanner leser = new Scanner(System.in); Scanner leser = new Scanner(System.in);
System.out.println("");
System.out.println("Bitte einloggen");
System.out.print("Telefonnummer: "); System.out.print("Telefonnummer: ");
String phoneNumber = leser.nextLine(); String phoneNumber = leser.nextLine();
System.out.print("Passwort: "); System.out.print("Passwort: ");
String password = leser.nextLine(); String password = leser.nextLine();
while(password.isEmpty() || phoneNumber.isEmpty())
{
System.out.println("Login fehlgeschlagen. Versuchen Sie es erneut.");
System.out.println("");
System.out.print("Telefonnummer: ");
phoneNumber = leser.nextLine();
System.out.print("Passwort: ");
password = leser.nextLine();
}
login.Einloggen(userData.readUser(), password, phoneNumber); login.Einloggen(userData.readUser(), password, phoneNumber);
} }
//EXECUTE LOGIN
// Data datei = new Data("users.txt");
// ArrayList<User> user = datei.readUser();
//
// 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);
//
// while (true) {
//
//
// System.out.print("Name: ");
// boolean error = false;
// String name = leser.nextLine();
// error = isError(error, name);
// System.out.print("Passwort: ");
// String password = leser.nextLine();
// error = isError(error, password);
//
//
// 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;
// }
// }
// }
//
// private static boolean isError(boolean error, String name) {
// if (name.isEmpty()) {
// error = true;
// }
// return error;
// }
} }

View File

@ -16,8 +16,7 @@ public class Login {
for (User user1 : user) { for (User user1 : user) {
if (!error) { if (!error) {
if (user1.getPassword().equals(password) && user1.getPhonenumber().equals(phoneNumber)) if (user1.getPassword().equals(password) && user1.getPhonenumber().equals(phoneNumber)) {
{
System.out.println(""); System.out.println("");
System.out.println("\t\t\tANMELDUNG"); System.out.println("\t\t\tANMELDUNG");
System.out.println(); System.out.println();
@ -25,8 +24,7 @@ public class Login {
i++; i++;
break; break;
} }
else if (!(user1.getPassword().equals(password) && user1.getPhonenumber().equals(phoneNumber))) else if (!(user1.getPassword().equals(password) && user1.getPhonenumber().equals(phoneNumber))) {
{
System.out.println("Login fehlgeschlagen. Versuchen Sie es erneut."); System.out.println("Login fehlgeschlagen. Versuchen Sie es erneut.");
System.out.println(""); System.out.println("");
System.out.print("Telefonnummer: "); System.out.print("Telefonnummer: ");
@ -43,8 +41,7 @@ public class Login {
} }
} }
public boolean isError ( boolean error, String phoneNumber) public boolean isError(boolean error, String phoneNumber) {
{
if (phoneNumber.isEmpty()) { if (phoneNumber.isEmpty()) {
error = true; error = true;
} }