Login ist jetzt auf english und kommentare wurden ergänzt.

This commit is contained in:
Kevin Pfannenstiel 2022-12-21 17:01:06 +01:00
parent de77901f5a
commit 12a8806fb6
5 changed files with 36 additions and 22 deletions

View File

@ -26,6 +26,12 @@ public class Execute {
+ "1: Nitrit-Pökelsalz; 2: Phosphat; 3: Nitrat; 4: Antioxidationsmittel; 5: Farbstoff;\n" + "1: Nitrit-Pökelsalz; 2: Phosphat; 3: Nitrat; 4: Antioxidationsmittel; 5: Farbstoff;\n"
+ "6: Geschmacksverstärker; 7: Süßungsmittel; 8: Konservierungsstoff"); + "6: Geschmacksverstärker; 7: Süßungsmittel; 8: Konservierungsstoff");
/**
* In the Login-Area the user can type the phonenumber and the password to login.
* In the Background, the class Login checks the input and return whether the login was correct or not.
*
* @author Kevin Pfannenstiel
*/
System.out.println(""); System.out.println("");
System.out.println("____________________________LOGIN_______________________________"); System.out.println("____________________________LOGIN_______________________________");
Data userData = new Data("user.txt"); Data userData = new Data("user.txt");
@ -38,18 +44,6 @@ public class Execute {
System.out.print("Passwort: "); System.out.print("Passwort: ");
String password = leser.nextLine(); String password = leser.nextLine();
while(password.isEmpty() || phoneNumber.isEmpty()) login.toLogin(userData.readUser(), password, phoneNumber);
{
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);
} }
} }

View File

@ -1,14 +1,6 @@
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.DayOfWeek; import java.time.DayOfWeek;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale; import java.util.Locale;
/** /**

View File

@ -2,7 +2,17 @@ import java.util.ArrayList;
import java.util.Scanner; import java.util.Scanner;
public class Login { public class Login {
public void Einloggen(ArrayList<User> user, String password, String phoneNumber) { /**
* The method toLogin() compares the phonenumber and password of the user with the phonenumber and password
* from the user.txt
*
* @param user all users are in a list
* @param password password of the user
* @param phoneNumber phonenumber of the user
* @return void
* @author Kevin Pfannenstiel
*/
public void toLogin(ArrayList<User> user, String password, String phoneNumber) {
Scanner leser = new Scanner(System.in); Scanner leser = new Scanner(System.in);
@ -11,6 +21,16 @@ public class Login {
while (true) { while (true) {
while(password.isEmpty() || phoneNumber.isEmpty())
{
System.out.println("Login fehlgeschlagen. Eingabe ist leer, versuchen Sie es erneut.");
System.out.println("");
System.out.print("Telefonnummer: ");
phoneNumber = leser.nextLine();
System.out.print("Passwort: ");
password = leser.nextLine();
}
boolean error = false; boolean error = false;
error = isError(error, phoneNumber); error = isError(error, phoneNumber);
@ -41,6 +61,14 @@ public class Login {
} }
} }
/**
* The method getDayNumberNew() checks if the phonenumber-input is empty.
*
* @param error is a boolean
* @param phoneNumber is the input of the user
* @return the boolean error
* @author Madeleine Vigier
*/
public boolean isError(boolean error, String phoneNumber) { public boolean isError(boolean error, String phoneNumber) {
if (phoneNumber.isEmpty()) { if (phoneNumber.isEmpty()) {
error = true; error = true;