Login ergänzt
This commit is contained in:
parent
739e973cf7
commit
2d683b9cc6
Binary file not shown.
Binary file not shown.
@ -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
|
||||
|
45
src/Login.java
Normal file
45
src/Login.java
Normal file
@ -0,0 +1,45 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Login {
|
||||
public void Einloggen(ArrayList<User> 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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user