From 2d683b9cc6298e2b220b31b992c879afa6f3e6a3 Mon Sep 17 00:00:00 2001 From: Kevin Pfannenstiel Date: Tue, 20 Dec 2022 19:12:54 +0100 Subject: [PATCH] =?UTF-8?q?Login=20erg=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- out/production/VPR_SCRIPT/Execute.class | Bin 1598 -> 2335 bytes out/production/VPR_SCRIPT/User.class | Bin 1752 -> 1752 bytes src/Execute.java | 21 +++++++++++ src/Login.java | 45 ++++++++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 src/Login.java diff --git a/out/production/VPR_SCRIPT/Execute.class b/out/production/VPR_SCRIPT/Execute.class index 26680c8e84c95457ddb0709064fe6f84c10d5d32..e58be0a4f596e55d00c87c2fd3c3e583c5b276bb 100644 GIT binary patch delta 929 zcmaKq%TE(g6vlr;J4`7xKzW3kD4;Qd3e~tVJQR_KXay8RswfOFl)-jd$`tU~xO8Pm z6E`eeXyU>RuqZ|nT$;EbZd{qjKjBIf;+a;A3&SkVz31HT-1B|koh{!hzxVU*hb^Fu z^qTjjEA6380S^}x+Q;_!Lj66xefyj{M;TH~@p*{r^x2UE5g4GvD~mSrT12yn&6RYD2{rln9B%3;iSu-8hY z>_Ize=&=?rJ@old=~t+(|1YFr*u!<9HDpAM>9}R3VlgAxT?DxNxSXrY{iEl$M{0t)5%DgSzynQ+gR>lDaqBT=vvN}SB>xU0@iNzKU+ zJ%&VIZm%*;M6x1gFdZx?KXA+c0Xvy`buPV5wZApXF=svhXWh%&CEr8~`#Ux$?%Sj@ zyg_%fdy}5MRE( zdda*~o6?7Pz+s-r3qGfoW$IYr2yZybD#v+GJs)Y{6DQc_B;Pp2ch2Ngj*7A}M&!Et zxCB*0l$iLiO(~Y_G)E_K61ibtnIkDKl<6ty*_^yr1ugraUqxmtStKnJ6Z_ pa>K259rDDKJAG1!SNHzOy~u+|hS`xioTC~1lK*fd&rF?=`5$C=9)kb? diff --git a/out/production/VPR_SCRIPT/User.class b/out/production/VPR_SCRIPT/User.class index cffb6de048d26c16c0cda1624035b4621eeadb01..ce14ec6abe0ca80e3a9596bbc69d5542f32daf37 100644 GIT binary patch delta 17 Zcmcb?dxMwb)W2Q(7#J9AH*#EH0{}$^2HyYx delta 17 Zcmcb?dxMwb)W2Q(7#J9AHga5G0{}$<2HpSw 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; + } +} +