diff --git a/out/production/VPR_SCRIPT/Execute.class b/out/production/VPR_SCRIPT/Execute.class index 26680c8..e58be0a 100644 Binary files a/out/production/VPR_SCRIPT/Execute.class and b/out/production/VPR_SCRIPT/Execute.class differ diff --git a/out/production/VPR_SCRIPT/User.class b/out/production/VPR_SCRIPT/User.class index cffb6de..ce14ec6 100644 Binary files a/out/production/VPR_SCRIPT/User.class and b/out/production/VPR_SCRIPT/User.class differ diff --git a/src/Execute.java b/src/Execute.java index 7943e86..ddcc5b4 100644 --- a/src/Execute.java +++ b/src/Execute.java @@ -25,6 +25,27 @@ public class Execute { + "i: Sesam; j: Schwefeldioxid und Sulfit; k: Nüsse; l: Sellerie; m: Fische; n: Lupinen\n" + "1: Nitrit-Pökelsalz; 2: Phosphat; 3: Nitrat; 4: Antioxidationsmittel; 5: Farbstoff;\n" + "6: Geschmacksverstärker; 7: Süßungsmittel; 8: Konservierungsstoff"); + + System.out.println(""); + System.out.println("____________________________LOGIN_______________________________"); + System.out.println(""); + System.out.println("Bitte einloggen"); + Data userData = new Data("user.txt"); + Login login = new Login(); + Scanner leser = new Scanner(System.in); + + while(true) + { + System.out.print("Telefonnummer: "); + String phoneNumber = leser.nextLine(); + System.out.print("Passwort: "); + String password = leser.nextLine(); + login.Einloggen(userData.readUser(), password, phoneNumber); + + } + + + } //EXECUTE LOGIN diff --git a/src/Login.java b/src/Login.java new file mode 100644 index 0000000..2e5dbf9 --- /dev/null +++ b/src/Login.java @@ -0,0 +1,45 @@ +import java.util.ArrayList; + +public class Login { + public void Einloggen(ArrayList user, String password, String phoneNumber) { + + System.out.println(); + System.out.println("\t\t\tANMELDUNG"); + int i = 0; + + while (true) { + + boolean error = false; + error = isError(error, phoneNumber); + + for (User user1 : user) { + if (!error) { + if (user1.getPassword().equals(password) && user1.getPhonenumber().equals(phoneNumber)) + { + 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(phoneNumber))) + { + System.out.println("Login fehlgeschlagen. Versuchen Sie es erneut."); + break; + } + } + } + if (i > 0) { + break; + } + } + } + + public boolean isError ( boolean error, String phoneNumber) + { + if (phoneNumber.isEmpty()) { + error = true; + } + return error; + } +} +