Merge remote-tracking branch 'origin/master'

This commit is contained in:
Kevin Pfannenstiel 2022-12-19 10:07:47 +01:00
commit 487bdd8fe0
16 changed files with 736 additions and 211 deletions

124
.idea/uiDesigner.xml generated Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

20
menue.txt Normal file
View File

@ -0,0 +1,20 @@
12.12.2022;Veganes Schnitzel;mit Kroketten und Gemüse;Vegan;x;;;;;;x;;;;x;;;;;;;x;;;;;x
12.12.2022;Vegane Waffel;mit Puderzucker;Dessert V;;;x;;x;;;;;x;;;;;;;x;;;;;;x
12.12.2022;Schnitzel;mit Kroketten, Gemüse und Soße;Fleisch;;;x;;;;;x;;;x;;;;;;;;x;;;;x
12.12.2022;Wackelpudding;mit Vanillesoße;Dessert;;;x;;;;;x;;;;;;;;x;;;;;x;;x
13.12.2022;Rote Linsen Curry;mit Süßkartoffeln;Vegan;;;x;;;;;;;;x;;;;;;x;;;;;;x
13.12.2022;Vegane Pancakes;mit Ahornsirup;Dessert V;x;;;;x;;;;x;;;;;x;;;;;;;;;x
13.12.2022;Gebratene Nudeln;mit Gemüse;Vegetarisch;;;;;;x;;;x;;x;;x;;;x;;;;;;;x
13.12.2022;Berliner;mit Erdbeerfüllung;Dessert;;;x;;;x;;;;x;;;;;x;;;;;x;;;x
14.12.2022;Bratkartoffeln;mit veganer Bratensoße;Vegan;;x;;;;x;;;;;;x;;;;;x;;;;;;x
14.12.2022;Pudding;mit Schokostreuseln;Dessert V;x;;x;;;x;;;x;;;;;;;x;;;;;;;x
14.12.2022;Bratkartoffeln;mit Leberkäse und Ei;Fleisch;;;;x;;x;;;x;;;;x;;;;;;;;;;x
14.12.2022;Pudding;mit Vanillesoße;Dessert;;;x;;;x;;x;;;x;;;;;;x;;;;;;x
15.12.2022;Bauerntopf;mit veganem Hack;Vegan;;x;;;;;;;;;x;;;;x;;;;x;;;;x
15.12.2022;Bananenbrot;mit Datteln;DessertV;;;x;;;x;;;;x;;;;;x;;;;;;;;x
15.12.2022;Bauerntopf;mit veganem Hack;Vegan;;x;;;;;;;;;x;;;;x;;;;x;;;;x
15.12.2022;Bananenbrot;mit Datteln;DessertV;;;x;;;x;;;;x;;;;;x;;;;;;;;x
16.12.2022;Bauerntopf;mit veganem Hack;Vegan;;x;;;;;;;;;x;;;;x;;;;x;;;;x
16.12.2022;Bananenbrot;mit Datteln;DessertV;;;x;;;x;;;;x;;;;;x;;;;;;;;x
16.12.2022;Bauerntopf;mit veganem Hack;Vegan;;x;;;;;;;;;x;;;;x;;;;x;;;;x
16.12.2022;Bananenbrot;mit Datteln;DessertV;;;x;;;x;;;;x;;;;;x;;;;;;;;x

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

239
src/Data.java Normal file
View File

@ -0,0 +1,239 @@
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;
/**
* Data is a class to edit files.
*
* @author Madeleine Vigier
* @version 1.3
*/
public class Data {
private String pathRead;
public Data(String pathRead) {
this.pathRead = pathRead;
}
/**
* readUser() is a method to split user.txt into lines and save them in an arraylist
*
* @return Arraylist userList
* @author Madeleine Vigier, Sabine Gubitz
* @version 1.3
*/
public ArrayList<User> readUser() {
List<String> rows = getRows();
ArrayList<User> 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];
userList.add(new User(nameParent1, nameParent2, billAddress, phonenumber, nameChildren, password));
}
return userList;
}
/**
* readMenue() is a method to split menue.txt into lines and save them in an arraylist
*
* @return Arraylist menuelist
* @author Madeleine Vigier, Sabine Gubitz
* @version 1.3
*/
public ArrayList<Menue> readMenue() {
List<String> rows = getRows();
ArrayList<Menue> menueList = new ArrayList<>();
for (String row : rows) {
String[] parts = row.split(";");
String date = parts[0];
String dish = parts[1];
String sideDish = parts[2];
String typ = parts[3];
String ingredient = parts[4];
List<String> ingredients = new ArrayList<>();
if (!ingredient.isEmpty()) {
ingredients.add("a"); //eggs
}
ingredient = parts[5];
if (!ingredient.isEmpty()) {
ingredients.add("d"); //peanuts
}
ingredient = parts[6];
if (!ingredient.isEmpty()) {
ingredients.add("m"); //fish
}
ingredient = parts[7];
if (!ingredient.isEmpty()) {
ingredients.add("g"); //grains
}
ingredient = parts[8];
if (!ingredient.isEmpty()) {
ingredients.add("f"); //crustaceans
}
ingredient = parts[9];
if (!ingredient.isEmpty()) {
ingredients.add("n"); //lupines
}
ingredient = parts[10];
if (!ingredient.isEmpty()) {
ingredients.add("c"); //milk
}
ingredient = parts[11];
if (!ingredient.isEmpty()) {
ingredients.add("k"); //nuts
}
ingredient = parts[12];
if (!ingredient.isEmpty()) {
ingredients.add("j"); //sulfurDioxideAndSulfite
}
ingredient = parts[13];
if (!ingredient.isEmpty()) {
ingredients.add("l"); //celeriac
}
ingredient = parts[14];
if (!ingredient.isEmpty()) {
ingredients.add("h"); //mustards
}
ingredient = parts[15];
if (!ingredient.isEmpty()) {
ingredients.add("i"); //sesame
}
ingredient = parts[16];
if (!ingredient.isEmpty()) {
ingredients.add("b");//soy
}
ingredient = parts[17];
if (!ingredient.isEmpty()) {
ingredients.add("e");//molluscs
}
ingredient = parts[18];
if (!ingredient.isEmpty()) {
ingredients.add("4"); //antioxidant
}
ingredient = parts[19];
if (!ingredient.isEmpty()) {
ingredients.add("5");
}
ingredient = parts[20];
if (!ingredient.isEmpty()) {
ingredients.add("6"); //flavourEnhancer
}
ingredient = parts[21];
if (!ingredient.isEmpty()) {
ingredients.add("8"); // preservatives
}
ingredient = parts[22];
if (!ingredient.isEmpty()) {
ingredients.add("3"); //nitrate
}
ingredient = parts[23];
if (!ingredient.isEmpty()) {
ingredients.add("1");//picklingSalt
}
ingredient = parts[24];
if (!ingredient.isEmpty()) {
ingredients.add("7"); //artificialSweetener
}
ingredient = parts[25];
if (!ingredient.isEmpty()) {
ingredients.add("2"); //phosphate
}
String end = parts[26]; //endpoint
menueList.add(new Menue(date, dish, sideDish, typ, ingredients));
}
return menueList;
}
/**
* readOrder() is a method to split order.txt into lines and save them in an arraylist
*
* @return Arraylist orderlist
* @author Madeleine Vigier, Sabine Gubitz
* @version 1.2
*/
public ArrayList<Order> readOrder() {
ArrayList<String> 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))
}
return null;//orderList
}
/**
* The method writeData 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 writeData(String pathWrite, ArrayList<String> listToWrite) {
if (pathWrite.equals("users.txt")) {
} else if (pathWrite.equals("orders.txt")) {
}
}
/**
* The method gets the rows by reading all lines of the path
*
* @return ArrayList rows
* @author Madeleine Vigier
* @version 1.0
*/
private List<String> getRows() {
Path path = Paths.get(pathRead);
List<String> rows = new ArrayList<>();
try {
rows = Files.readAllLines(path);
} catch (IOException e) {
e.printStackTrace();
}
return rows;
}
}

View File

@ -1,66 +0,0 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
public class Datei {
private String dataName;
public Datei(String dataName) {
this.dataName = dataName;
}
public User[] laden() {
Path pfad = Paths.get(dataName);
try {
List<String> zeilen = Files.readAllLines(pfad);
User[] userListe = new User[zeilen.size()];
for (int i = 0; i < zeilen.size(); i++) {
String[] teile = zeilen.get(i).split(":");
String nameParent1 = teile[0];
String nameParent2 = teile[1];
String billAddress = teile[2];
String phonenumber = teile[3];
String nameChildren = teile[4];
String password = teile[5];
userListe[i] = new User(nameParent1, nameParent2, billAddress, phonenumber, nameChildren, password);
}
return userListe;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
// public void speichern(Farbe[] farben, String dateiName) {
//
// Path pfad = Paths.get(dateiname);
//
// List<String> zeilen = new ArrayList<>();
// for (Farbe farbe : farben) {
// zeilen.add(farbe.formatieren());
//
// }
// try {
// Files.write(pfad, zeilen);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
}

View File

@ -2,57 +2,84 @@ import java.util.ArrayList;
import java.util.Scanner;
/**
* The class Execute is the executen file for the whole programm.
* The class Execute is the execution file for the whole program.
*/
public class Execute {
public static void main(String[] args) {
Datei datei = new Datei("user.txt");
User[] user = datei.laden();
//EXECUTE MENUE OVERVIEW
Data data = new Data("menue.txt");
ArrayList<Menue> menue = data.readMenue();
for (User user1 : user) {
System.out.println(user1);
for (int i = 0; i < menue.size(); i++) {
if (i % 4 == 0) {
System.out.println();
System.out.println("--------------------------------------");
System.out.println(GeneralMethods.getDayNumberNew(menue.get(i).getDate()));
System.out.println(menue.get(i).getDate());
System.out.println();
}
System.out.println(menue.get(i));
}
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();
if(name.isEmpty()){
error = true;
}
System.out.print("Passwort: ");
String password = leser.nextLine();
if(password.isEmpty()){
error = true;
}
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;
}
}
System.out.println("a: Eier; b: Soja, c: Milch; d: Erdnüsse; e: Weichtiere; f: Krebstiere; g: Getreide; h: Senf\n"
+ "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");
}
//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;
// }
}

View File

@ -4,120 +4,171 @@ 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;
/**GeneralMethods is a class for commen public methods.
*
* @auhtor Felix Wöstemeyer
/**
* GeneralMethods is a class for commen public methods.
*
* @version 1.0
* @auhtor Felix Wöstemeyer
*/
public class GeneralMethods {
/**The method writeData saves the given data to a certain file.
/**
* The method getDayNumberNew() gets the Number of day in week
*
* @param pathWrite the given filepath to write
* @param data the data to be saved
* @param dateString date as String e.g. 12.12.2022
* @return the Number of day in week
* @version 1.0
* @author Madeleine Vigier
*/
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();
}
public static String getDayNumberNew(String dateString) {
//https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
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);
DayOfWeek day = date.getDayOfWeek();
return getDayName(day.getValue());
}
/**
* 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
* The method getDayName() gets the weekday
*
* @param pathRead determines the filename of the file that will be read
* @return menueList, userList, orderList depending on Data read
* @param dayNumber dayNumber e.g. 1 for Monday
* @return weekday
* @version 1.0
* @author Madeleine Vigier
*/
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();
public static String getDayName(int dayNumber) {
if (dayNumber == 1) {
return "Montag";
}
if (dayNumber == 2) {
return "Dienstag";
}
if (dayNumber == 3) {
return "Mittwoch";
}
if (dayNumber == 4) {
return "Donnerstag";
}
if (dayNumber == 5) {
return "Freitag";
}
return null;
}
/**
* The method writeData 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")) {
}
}
// /**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")) {
//
// }
// }
}

75
src/Menue.java Normal file
View File

@ -0,0 +1,75 @@
import java.util.List;
/**
* Menue is a class to built a menue
*
* @author: Madeleine Vigier
* @version: 1.0
*/
public class Menue {
String date;
String dish;
String sideDish;
String typ;
List<String> ingredients;
/**
* constructor
*
* @param date date of meal
* @param dish meal
* @param sideDish side dish
* @param typ vegan, vegetarian or meat
* @param ingredients list of ingredients
*/
public Menue(String date, String dish, String sideDish, String typ, List<String> ingredients) {
this.date = date;
this.dish = dish;
this.sideDish = sideDish;
this.typ = typ;
this.ingredients = ingredients;
}
/**
* The method get Date() gets the date
*
* @return date
* @author Madeleine Vigier
* @version 1.0
*/
public String getDate() {
return date;
}
/**
* The method getTyp() gets the typ of the meal
*
* @return typ e.g. Vegan
* @author Madeleine Vigier
* @version 1.0
*/
public String getTyp() {
if (typ.contains("DessertV") || typ.contains("Dessert")) {
return "";
} else {
return typ;
}
}
/**
* The method toString() returns a String representation of an object
*
* @return a String with dish, sideDish, list of ingredients and the typ of the menue
* @author Madeleine Vigier
* @version 1.0
*/
@Override
public String toString() {
return dish + "\n" + sideDish
+ "\n" + ingredients.toString().replace("[", "").replace("]", "") + "\n" + getTyp() + "\n";
}
}

2
src/Order.java Normal file
View File

@ -0,0 +1,2 @@
public class Order {
}

View File

@ -1,3 +1,9 @@
/**
* User class creates User Objects
*
* @author Madeleine Vigier
* @version 1.1
*/
public class User {
private String nameParent1;
private String nameParent2;
@ -6,6 +12,18 @@ public class User {
private String nameChildren;
private String password;
/**
* constructor
*
* @param nameParent1
* @param nameParent2
* @param billAddress
* @param phonenumber
* @param nameChildren
* @param password
* @author Madeleine Vigier
* @version 1.0
*/
public User(String nameParent1, String nameParent2, String billAddress, String phonenumber, String nameChildren, String password) {
this.nameParent1 = nameParent1;
this.nameParent2 = nameParent2;
@ -15,22 +33,57 @@ public class User {
this.password = password;
}
/**
* the method getPhonenumber() gets the Phonenumber
*
* @return Phonenumber
* @author Madeleine Vigier
* @version 1.0
*/
public String getPhonenumber() {
return phonenumber;
}
/**
* the method getPassword() gets the password
*
* @return password
* @author Madeleine Vigier
* @version 1.0
*/
public String getPassword() {
return password;
}
/**
* the method getNameParent1() gets nameParent1
*
* @return nameParent1
* @author Madeleine Vigier
* @version 1.0
*/
public String getNameParent1() {
return nameParent1;
}
/**
* the method getNameParent2() gets nameParent2
*
* @return nameParent2
* @author Madeleine Vigier
* @version 1.0
*/
public String getNameParent2() {
return nameParent2;
}
/**
* the methode toString() returns a String representation of an object
*
* @return a String with nameParent1, nameparent2, billAdress, phonenumber, nameChildren, password
* @author Madeleine Vigier
* @version 1.0
*/
@Override
public String toString() {
return "User{" +

View File

@ -1,2 +1,2 @@
Felix Düsterhaus:Sabine Gubitz:Detmolderstrasse 101,33102 Paderborn:1234567:Lisa,Peter:12345
Kevin Pfannenstiel:Marlene Pfannenstiel:Fürstenallee 30, 33102 Paderborn:7654321:Anton:12345
Felix Düsterhaus;Sabine Gubitz;Detmolderstrasse 101,33102 Paderborn;1234567;Lisa,Peter;12345
Kevin Pfannenstiel;Marlene Pfannenstiel;Fürstenallee 30, 33102 Paderborn;7654321;Anton;12345