Compare commits
24 Commits
2d683b9cc6
...
master
Author | SHA1 | Date | |
---|---|---|---|
51e370ad33 | |||
f1fabad17d | |||
deeabfd2ad | |||
6ffc7a6868 | |||
7e507fa95c | |||
f35554f858 | |||
9663777e25 | |||
eeba57165b | |||
58ec030102 | |||
4baa3ef51b | |||
a44c87cf83 | |||
230202aa0a | |||
3df13417c7 | |||
d4a351a4e2 | |||
83af3a6066 | |||
d2f9ef49c9 | |||
d858ff8f8d | |||
95069e7d8d | |||
3c51ebbc21 | |||
644df46a7a | |||
19d36d3464 | |||
12a8806fb6 | |||
de77901f5a | |||
76d08d93da |
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
10
.idea/runConfigurations.xml
generated
10
.idea/runConfigurations.xml
generated
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
12
orders.txt
Normal file
12
orders.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
12.12.2022;1234567;Vegan;Dessert V
|
||||
12.12.2022;7654321;Vegan;Dessert V
|
||||
12.12.2022;123;Vegetarisch;Dessert V
|
||||
12.12.2022;9999999;Fleisch;Dessert
|
||||
12.12.2022;1234567;Vegan;Dessert V
|
||||
12.12.2022;7654321;Vegan;Dessert V
|
||||
12.12.2022;123;Vegetarisch;Dessert V
|
||||
12.12.2022;9999999;Fleisch;Dessert
|
||||
12.12.2022;1234567;Vegan;Dessert V
|
||||
12.12.2022;7654321;Vegan;Dessert V
|
||||
12.12.2022;123;Vegetarisch;Dessert V
|
||||
12.12.2022;1234;Fleisch;Dessert
|
12
orders2.txt
Normal file
12
orders2.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
12.12.2022;1234567;Vegan;Dessert V
|
||||
12.12.2022;7654321;Vegan;Dessert V
|
||||
12.12.2022;123;Vegetarisch;Dessert V
|
||||
12.12.2022;9999999;Fleisch;Dessert
|
||||
12.12.2022;1234567;Vegan;Dessert V
|
||||
12.12.2022;7654321;Vegan;Dessert V
|
||||
12.12.2022;123;Vegetarisch;Dessert V
|
||||
12.12.2022;9999999;Fleisch;Dessert
|
||||
12.12.2022;1234567;Vegan;Dessert V
|
||||
12.12.2022;7654321;Vegan;Dessert V
|
||||
12.12.2022;123;Vegetarisch;Dessert V
|
||||
12.12.2022;1234;Fleisch;Dessert
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
163
src/Data.java
163
src/Data.java
@@ -1,10 +1,14 @@
|
||||
import java.io.File;
|
||||
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.sql.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Data is a class to edit files.
|
||||
@@ -177,25 +181,17 @@ public class Data {
|
||||
*/
|
||||
public ArrayList<Order> readOrder() {
|
||||
|
||||
ArrayList<String> orderList = new ArrayList<>();
|
||||
ArrayList<Order> orderList = new ArrayList<>();
|
||||
List<String> rows = getRows();
|
||||
|
||||
for (String row : rows) {
|
||||
String[] parts = row.split(";");
|
||||
|
||||
String date = parts[0];
|
||||
String meat = parts[1];
|
||||
String meatCount = parts[2];
|
||||
String vegi = parts[3];
|
||||
String vegiCount = parts[4];
|
||||
String vegan = parts[5];
|
||||
String veganCount = parts[6];
|
||||
String desertV = parts[7];
|
||||
String desertVCount = parts[8];
|
||||
String desert = parts[9];
|
||||
String desertCount = parts[10];
|
||||
//orderList.add(new Order(date, meat, meatCount,vegi, vegiCount, vegan, veganCount, desertV,
|
||||
// desertVCount, desert, desertCount))
|
||||
String user = parts[1];
|
||||
String mealtype = parts[3];
|
||||
String deserttype = parts[5];
|
||||
orderList.add(new Order(date, user, mealtype, deserttype));
|
||||
}
|
||||
return null;//orderList
|
||||
|
||||
@@ -204,14 +200,30 @@ public class Data {
|
||||
/**
|
||||
* The method writeData writes the data of a List into a txt file.
|
||||
*
|
||||
* @author Felix Wöstemeyer
|
||||
*
|
||||
* @param pathWrite determines the filename of the file that will be written
|
||||
* @param listToWrite determines which ArrayList is to be used for writing the file
|
||||
*/
|
||||
public void writeData(String pathWrite, ArrayList<String> listToWrite) {
|
||||
if (pathWrite.equals("users.txt")) {
|
||||
|
||||
} else if (pathWrite.equals("orders.txt")) {
|
||||
|
||||
try {
|
||||
if (new File(pathWrite).exists()) {
|
||||
for (String zeile : listToWrite) {
|
||||
new FileWriter(pathWrite).write(zeile);
|
||||
}
|
||||
}else
|
||||
{
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
System.out.println("Der Pfad oder die Datei "+ pathWrite +" existiert nicht!\nMöchten Sie unter dem Pfad "+ pathWrite+ " eine neue Datei erstellen? (Y/N)");
|
||||
if(scanner.nextLine().equals("Y")){
|
||||
new File(pathWrite).createNewFile();
|
||||
System.out.println("Die Datei "+ pathWrite+" wurde erfolgreich erstellt");
|
||||
}else if(!scanner.nextLine().equals("N") && !scanner.nextLine().equals("Y")){
|
||||
System.out.println("Es ist ein Fehler mit ihrer Antwort aufgetreten!");
|
||||
}
|
||||
}
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,5 +243,120 @@ public class Data {
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method validates the user input
|
||||
*
|
||||
* @return boolean inputValid
|
||||
* @author Kevin Maier
|
||||
*/
|
||||
private boolean validateData(String password, String phoneNumber)
|
||||
{
|
||||
boolean inputValid = false;
|
||||
boolean phoneNumberMatchFound;
|
||||
boolean passwordMatchFound;
|
||||
boolean phoneNumberValid = false;
|
||||
boolean passwordValid = false;
|
||||
|
||||
Pattern phoneNumberPattern = Pattern.compile("[0-9]*");
|
||||
Pattern passwordPattern = Pattern.compile("^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{8,}$");
|
||||
|
||||
Scanner reader = new Scanner(System.in);
|
||||
|
||||
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 = reader.nextLine();
|
||||
System.out.print("Passwort: ");
|
||||
password = reader.nextLine();
|
||||
}
|
||||
|
||||
Matcher phoneNumberMatcher = phoneNumberPattern.matcher(phoneNumber);
|
||||
Matcher passwordMatcher = passwordPattern.matcher(password);
|
||||
|
||||
phoneNumberMatchFound = phoneNumberMatcher.find();
|
||||
passwordMatchFound = passwordMatcher.find();
|
||||
|
||||
while (!inputValid) {
|
||||
if (!phoneNumberMatchFound || phoneNumber.length() != 15) {
|
||||
System.out.println("Login fehlgeschlagen. Die eingegebene Handynummer ist nicht valide.");
|
||||
System.out.println("");
|
||||
System.out.print("Telefonnummer: ");
|
||||
phoneNumber = reader.nextLine();
|
||||
System.out.print("Passwort: ");
|
||||
password = reader.nextLine();
|
||||
} else {
|
||||
phoneNumberValid = true;
|
||||
}
|
||||
|
||||
if (!passwordMatchFound || password.length() < 6 || password.length() > 20) {
|
||||
System.out.println("Login fehlgeschlagen. Das eingegebene Passwort ist nicht valide.");
|
||||
System.out.println("");
|
||||
System.out.print("Telefonnummer: ");
|
||||
phoneNumber = reader.nextLine();
|
||||
System.out.print("Passwort: ");
|
||||
password = reader.nextLine();
|
||||
} else {
|
||||
passwordValid = true;
|
||||
}
|
||||
|
||||
if (phoneNumberValid && passwordValid) {
|
||||
inputValid = true;
|
||||
}
|
||||
}
|
||||
return inputValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method changes the orders.txt file by removing canceled orders
|
||||
*
|
||||
* @return ArrayList\<Order> changedOrderList
|
||||
* @author Felix Düsterhaus
|
||||
*/
|
||||
|
||||
public ArrayList<Order> changeOrder(String userLogin) {
|
||||
|
||||
/*
|
||||
File orderFile = new File("C:/Unterricht/VPR/orders.txt");
|
||||
if (orderFile.delete()) {
|
||||
System.out.println("Datei gelöscht: " + orderFile.getName());
|
||||
} else {
|
||||
System.out.println("Fehler, " + orderFile.getName() + " nicht gelöscht.");
|
||||
}
|
||||
*/
|
||||
|
||||
ArrayList<Order> changedOrderList = new ArrayList<>();
|
||||
List<String> rows = getRows();
|
||||
int changedEntries = 0;
|
||||
|
||||
for (String row : rows) {
|
||||
String[] parts = row.split(";");
|
||||
|
||||
String date = parts[0];
|
||||
String user = parts[1];
|
||||
String mealtyp = parts[2];
|
||||
String deserttyp = parts[3];
|
||||
if(!userLogin.equals(user)) {
|
||||
changedOrderList.add(new Order(date, user, mealtyp, deserttyp));
|
||||
} else {
|
||||
changedEntries++;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
FileWriter writer = new FileWriter("orders2.txt");
|
||||
for(Order str: changedOrderList) {
|
||||
writer.write(str + System.lineSeparator());
|
||||
}
|
||||
writer.close();
|
||||
System.out.println("Daten gelöscht");
|
||||
System.out.println(changedEntries + " Einträge entfernt.");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return changedOrderList;
|
||||
}
|
||||
}
|
||||
|
||||
|
101
src/Execute.java
101
src/Execute.java
@@ -1,3 +1,5 @@
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
@@ -5,8 +7,8 @@ import java.util.Scanner;
|
||||
* The class Execute is the execution file for the whole program.
|
||||
*/
|
||||
public class Execute {
|
||||
public static void main(String[] args) {
|
||||
//EXECUTE MENUE OVERVIEW
|
||||
public static void main(String[] args) throws IOException {
|
||||
//EXECUTE MENU OVERVIEW
|
||||
Data data = new Data("menue.txt");
|
||||
ArrayList<Menu> menu = data.readMenu();
|
||||
|
||||
@@ -26,81 +28,48 @@ public class Execute {
|
||||
+ "1: Nitrit-Pökelsalz; 2: Phosphat; 3: Nitrat; 4: Antioxidationsmittel; 5: Farbstoff;\n"
|
||||
+ "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("____________________________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.println("");
|
||||
System.out.println("Bitte einloggen");
|
||||
System.out.print("Telefonnummer: ");
|
||||
String phoneNumber = leser.nextLine();
|
||||
System.out.print("Passwort: ");
|
||||
String password = leser.nextLine();
|
||||
login.Einloggen(userData.readUser(), password, phoneNumber);
|
||||
|
||||
login.toLogin(userData.readUser(), password, phoneNumber);
|
||||
|
||||
/**
|
||||
* Test zum Daten löschen
|
||||
* @author Felix Düsterhaus
|
||||
*/
|
||||
Data orderData = new Data("orders2.txt");
|
||||
System.out.print("Möchten Sie Einträge löschen? (Y/N) ");
|
||||
String orderChangeDecision = leser.nextLine();
|
||||
if (orderChangeDecision.equals("Y") || orderChangeDecision.equals("y")) {
|
||||
ArrayList<Order> changedOrderList = orderData.changeOrder(phoneNumber);
|
||||
} else if (orderChangeDecision.equals("N") || orderChangeDecision.equals("n")) {
|
||||
System.out.println("Daten werden nicht geändert.");
|
||||
}
|
||||
while(!(orderChangeDecision.equals("Y") || orderChangeDecision.equals("y") || orderChangeDecision.equals("N") || orderChangeDecision.equals("n"))) {
|
||||
System.out.println("Bitte eine gültige Aussage treffen.\n");
|
||||
System.out.print("Möchten Sie Einträge löschen? (Y/N) ");
|
||||
orderChangeDecision = leser.nextLine();
|
||||
|
||||
|
||||
|
||||
if (orderChangeDecision.equals("Y") || orderChangeDecision.equals("y")) {
|
||||
ArrayList<Order> changedOrderList = orderData.changeOrder(phoneNumber);
|
||||
} else if (orderChangeDecision.equals("N") || orderChangeDecision.equals("n")) {
|
||||
System.out.println("Daten werden nicht geändert.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//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;
|
||||
// }
|
||||
}
|
||||
|
@@ -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.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
@@ -27,7 +19,7 @@ public class GeneralMethods {
|
||||
* @author Madeleine Vigier
|
||||
*/
|
||||
public static String getDayNumberNew(String dateString) {
|
||||
//https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
|
||||
//https://stackoverflow.com/questions/8746084/string-to-localdate
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
||||
formatter = formatter.withLocale(Locale.GERMANY); // Locale specifies human language for translating, and cultural norms for lowercase/uppercase and abbreviations and such. Example: Locale.US or Locale.CANADA_FRENCH
|
||||
LocalDate date = LocalDate.parse(dateString, formatter);
|
||||
@@ -40,7 +32,7 @@ public class GeneralMethods {
|
||||
* The method getDayName() gets the weekday
|
||||
*
|
||||
* @param dayNumber dayNumber e.g. 1 for Monday
|
||||
* @return weekday
|
||||
* @return String weekday
|
||||
* @author Madeleine Vigier
|
||||
*/
|
||||
public static String getDayName(int dayNumber) {
|
||||
@@ -63,110 +55,4 @@ public class GeneralMethods {
|
||||
return null;
|
||||
}
|
||||
|
||||
// /**The method writeData saves the given data to a certain file.
|
||||
// *
|
||||
// * @param pathWrite the given filepath to write
|
||||
// * @param data the data to be saved
|
||||
// */
|
||||
// public static void writeData(String pathWrite, ArrayList<String> data){
|
||||
// try{
|
||||
// BufferedWriter writer = new BufferedWriter(new FileWriter(pathWrite));
|
||||
// for (String d : data) {
|
||||
// writer.write(d);
|
||||
// writer.newLine();
|
||||
// }
|
||||
// writer.close();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Author: Sabine Gubitz
|
||||
// *ddd
|
||||
// * The method read Data interprets a file and returns an useable list for other methods.
|
||||
// * Files to be read have to use : as a divider between attributes
|
||||
// *
|
||||
// * @param pathRead determines the filename of the file that will be read
|
||||
// * @return menueList, userList, orderList depending on Data read
|
||||
// */
|
||||
// public static ArrayList<String> readData(String pathRead) {
|
||||
// Path path = Paths.get(pathRead);
|
||||
//
|
||||
// try {
|
||||
// List<String> rows = Files.readAllLines(path);
|
||||
//
|
||||
// if (pathRead.equals("menue.txt")) {
|
||||
// ArrayList<String> menueList = new ArrayList<>();
|
||||
//
|
||||
// for (String row : rows) {
|
||||
// String[] parts = row.split(":");
|
||||
//
|
||||
// String day = parts[0];
|
||||
// String date = parts[1];
|
||||
// String meat = parts[2];
|
||||
// String vegi = parts[3];
|
||||
// String vegan = parts[4];
|
||||
// String desert1 = parts[5];
|
||||
// String desert2 = parts[6];
|
||||
// menueList.add(day + "," + date + "," + meat + "," + vegi + "," + vegan + "," + desert1 + "," + desert2);
|
||||
// }
|
||||
// return menueList;
|
||||
//
|
||||
// } else if (pathRead.equals("users.txt")){
|
||||
// ArrayList<String> userList = new ArrayList<>();
|
||||
//
|
||||
// for (String row : rows) {
|
||||
// String[] parts = row.split(":");
|
||||
//
|
||||
// String nameParent1 = parts[0];
|
||||
// String nameParent2 = parts[1];
|
||||
// String billAddress = parts[2];
|
||||
// String phonenumber = parts[3];
|
||||
// String nameChildren = parts[4];
|
||||
// String password = parts[5];
|
||||
// }
|
||||
// return userList;
|
||||
//
|
||||
// } else if (pathRead.equals("orders.txt")) {
|
||||
// ArrayList<String> orderList = new ArrayList<>();
|
||||
//
|
||||
// for (String row : rows) {
|
||||
// String[] parts = row.split(":");
|
||||
//
|
||||
// String date = parts[0];
|
||||
// String meat = parts[1];
|
||||
// String meatCount = parts[2];
|
||||
// String vegi = parts[3];
|
||||
// String vegiCount = parts[4];
|
||||
// String vegan = parts[5];
|
||||
// String veganCount = parts[6];
|
||||
// String desert1 = parts[7];
|
||||
// String desert1Count = parts[8];
|
||||
// String desert2 = parts[9];
|
||||
// String desert2Count = parts[10];
|
||||
// }
|
||||
// return orderList;
|
||||
//
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * The method writeData2 writes the data of a List into a txt file.
|
||||
// * @param pathWrite determines the filename of the file that will be written
|
||||
// * @param listToWrite determines which ArrayList is to be used for writing the file
|
||||
// */
|
||||
// public void writeData2 (String pathWrite, ArrayList<String> listToWrite){
|
||||
// if (pathWrite.equals("users.txt")) {
|
||||
//
|
||||
// } else if (pathWrite.equals("orders.txt")) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
@@ -1,10 +1,22 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
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);
|
||||
|
||||
System.out.println();
|
||||
System.out.println("\t\t\tANMELDUNG");
|
||||
int i = 0;
|
||||
|
||||
while (true) {
|
||||
@@ -14,16 +26,21 @@ public class Login {
|
||||
|
||||
for (User user1 : user) {
|
||||
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("\t\t\tANMELDUNG");
|
||||
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)))
|
||||
{
|
||||
else if (!(user1.getPassword().equals(password) && user1.getPhonenumber().equals(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();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -34,8 +51,15 @@ public class Login {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isError ( boolean error, String phoneNumber)
|
||||
{
|
||||
/**
|
||||
* 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) {
|
||||
if (phoneNumber.isEmpty()) {
|
||||
error = true;
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ public class Menu {
|
||||
String date;
|
||||
String dish;
|
||||
String sideDish;
|
||||
String typ;
|
||||
String type;
|
||||
List<String> ingredients;
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ public class Menu {
|
||||
* @param date date of meal
|
||||
* @param dish meal
|
||||
* @param sideDish side dish
|
||||
* @param typ vegan, vegetarian or meat
|
||||
* @param type vegan, vegetarian or meat
|
||||
* @param ingredients list of ingredients
|
||||
*/
|
||||
public Menu(String date, String dish, String sideDish, String typ, List<String> ingredients) {
|
||||
public Menu(String date, String dish, String sideDish, String type, List<String> ingredients) {
|
||||
this.date = date;
|
||||
this.dish = dish;
|
||||
this.sideDish = sideDish;
|
||||
this.typ = typ;
|
||||
this.type = type;
|
||||
this.ingredients = ingredients;
|
||||
}
|
||||
|
||||
@@ -47,26 +47,25 @@ public class Menu {
|
||||
* @return typ e.g. Vegan
|
||||
* @author Madeleine Vigier
|
||||
*/
|
||||
public String getTyp() {
|
||||
if (typ.contains("DessertV") || typ.contains("Dessert")) {
|
||||
public String getType() {
|
||||
if (type.contains("DessertV") || type.contains("Dessert")) {
|
||||
return "";
|
||||
} else {
|
||||
|
||||
return typ;
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The method toString() returns a String representation of an object
|
||||
* The method toString() returns a String formated to save in a File
|
||||
*
|
||||
* @return a String with dish, sideDish, list of ingredients and the typ of the menu
|
||||
* @author Madeleine Vigier
|
||||
* @author Madeleine Vigier, Felix Wöstemeyer
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return dish + "\n" + sideDish
|
||||
+ "\n" + ingredients.toString().replace("[", "").replace("]", "") + "\n" + getTyp() + "\n";
|
||||
return date+";"+dish+";"+sideDish+";"+type+";"+ingredients;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,2 +1,47 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* The class Order is an object class that holds the constructor for order objects.
|
||||
*
|
||||
* @author Sabine Gubitz
|
||||
* @version 1.2
|
||||
*/
|
||||
|
||||
public class Order {
|
||||
String date; //date for the meal, not the day it was ordered
|
||||
String user; //phone number of the user account
|
||||
String mealtype; //meat, vegi or vegan
|
||||
String desserttype; //desert or vegan desert
|
||||
|
||||
Order (String date, String user, String mealtype, String desserttype)
|
||||
{
|
||||
this.date = date;
|
||||
this.user = user;
|
||||
this.mealtype = mealtype;
|
||||
this.desserttype = desserttype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return date+";"+user+";"+mealtype+";"+desserttype;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Method create PDF is used to create a PDF document of the daily orders as well as the bills for each user
|
||||
*
|
||||
* This Method uses PDF Clown, the source code can be found at http://www.pdfclown.org
|
||||
* PDF Clown is covered by LGPL, a copy of the LGPL can be found withing the documentation
|
||||
*
|
||||
* @param pathWrite determines which document should be created
|
||||
* @param listToWrite determines the list which is to be used to create the document
|
||||
* @author Sabine Gubitz
|
||||
*/
|
||||
|
||||
public void createPDF (String pathWrite, ArrayList<String> listToWrite) {
|
||||
if (pathWrite.equals("users.pdf")) {
|
||||
|
||||
} else if (pathWrite.equals("bills.pdf")) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ public class User {
|
||||
* @param nameParent2 name of the second parent of the child
|
||||
* @param billAddress the address the bill should be sent to
|
||||
* @param phoneNumber phonenumber of one of the parents and also the username
|
||||
* @param nameChildren name of the child
|
||||
* @param nameChildren name of the children
|
||||
* @param password password of the user
|
||||
* @author Madeleine Vigier
|
||||
*/
|
||||
@@ -80,13 +80,6 @@ public class User {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"nameParent1='" + nameParent1 + '\'' +
|
||||
", nameParent2='" + nameParent2 + '\'' +
|
||||
", billAddress='" + billAddress + '\'' +
|
||||
", phonenumber='" + phoneNumber + '\'' +
|
||||
", nameChildren='" + nameChildren + '\'' +
|
||||
", password='" + password + '\'' +
|
||||
'}';
|
||||
return nameParent1 + ";" + nameParent2 + ";" + billAddress + ";" + phoneNumber + ";" + nameChildren + ";" + password;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user