menue methode angepasst

This commit is contained in:
Madeleine Vigier 2022-12-15 19:38:24 +01:00
parent c9206ed2da
commit 97686d48ca

View File

@ -7,6 +7,7 @@ import java.util.List;
/** /**
* Data is a class to edit files. * Data is a class to edit files.
*
* @author Madeleine Vigier * @author Madeleine Vigier
* @version 1.3 * @version 1.3
*/ */
@ -16,13 +17,15 @@ public class Data {
public Data(String pathRead) { public Data(String pathRead) {
this.pathRead = pathRead; this.pathRead = pathRead;
} }
/** /**
* readUser() is a method to split user.txt into lines and save them in an arraylist * readUser() is a method to split user.txt into lines and save them in an arraylist
*
* @return Arraylist userList * @return Arraylist userList
* @author Madeleine Vigier, Sabine Gubitz * @author Madeleine Vigier, Sabine Gubitz
* @version 1.3 * @version 1.3
*/ */
public ArrayList<User> readUser(){ public ArrayList<User> readUser() {
List<String> rows = getRows(); List<String> rows = getRows();
ArrayList<User> userList = new ArrayList<>(); ArrayList<User> userList = new ArrayList<>();
@ -35,7 +38,7 @@ public class Data {
String phonenumber = parts[3]; String phonenumber = parts[3];
String nameChildren = parts[4]; String nameChildren = parts[4];
String password = parts[5]; String password = parts[5];
userList.add(new User(nameParent1,nameParent2,billAddress,phonenumber,nameChildren,password)); userList.add(new User(nameParent1, nameParent2, billAddress, phonenumber, nameChildren, password));
} }
return userList; return userList;
@ -44,140 +47,140 @@ public class Data {
/** /**
* readMenue() is a method to split menue.txt into lines and save them in an arraylist * readMenue() is a method to split menue.txt into lines and save them in an arraylist
*
* @return Arraylist menuelist * @return Arraylist menuelist
* @author Madeleine Vigier, Sabine Gubitz * @author Madeleine Vigier, Sabine Gubitz
* @version 1.3 * @version 1.3
*/ */
public ArrayList<Menue> readMenue(){ public ArrayList<Menue> readMenue() {
ArrayList<Menue> menueList = new ArrayList<>();
List<String> rows = getRows();
List<String> rows = getRows();
ArrayList<Menue> menueList = new ArrayList<>();
for (String row : rows) { for (String row : rows) {
String[] parts = row.split(";"); String[] parts = row.split(";");
String date = parts[1]; String date = parts[0];
String dish = parts[2]; String dish = parts[1];
String sideDish = parts[3]; String sideDish = parts[2];
String typ = parts[4]; String typ = parts[3];
String desertV = parts[5]; String allergens = parts[4];
String desert = parts[6];
String allergens = parts[7];
boolean eggs = false; boolean eggs = false;
if (allergens != "") { if (allergens != "") {
eggs = true; eggs = true;
} }
allergens = parts[8]; allergens = parts[5];
boolean peanuts = false; boolean peanuts = false;
if (allergens != "") { if (allergens != "") {
peanuts = true; peanuts = true;
} }
allergens = parts[9]; allergens = parts[6];
boolean fish = false; boolean fish = false;
if (allergens != "") { if (allergens != "") {
fish = true; fish = true;
} }
allergens = parts[10]; allergens = parts[7];
boolean grains = false; boolean grains = false;
if (allergens != "") { if (allergens != "") {
grains = true; grains = true;
} }
allergens = parts[11]; allergens = parts[8];
boolean crustaceans = false; boolean crustaceans = false;
if (allergens != "") { if (allergens != "") {
crustaceans = true; crustaceans = true;
} }
allergens = parts[12]; allergens = parts[9];
boolean lupines = false; boolean lupines = false;
if (allergens != "") { if (allergens != "") {
lupines = true; lupines = true;
} }
allergens = parts[13]; allergens = parts[10];
boolean milk = false; boolean milk = false;
if (allergens != "") { if (allergens != "") {
milk = true; milk = true;
} }
allergens = parts[14]; allergens = parts[11];
boolean nuts = false; boolean nuts = false;
if (allergens != "") { if (allergens != "") {
nuts = true; nuts = true;
} }
allergens = parts[15]; allergens = parts[12];
boolean sulfurDioxideAndSulfite = false; boolean sulfurDioxideAndSulfite = false;
if (allergens != "") { if (allergens != "") {
sulfurDioxideAndSulfite = true; sulfurDioxideAndSulfite = true;
} }
allergens = parts[16]; allergens = parts[13];
boolean celeriac = false; boolean celeriac = false;
if (allergens != "") { if (allergens != "") {
celeriac = true; celeriac = true;
} }
allergens = parts[17]; allergens = parts[14];
boolean mustards = false; boolean mustards = false;
if (allergens != "") { if (allergens != "") {
mustards = true; mustards = true;
} }
allergens = parts[18]; allergens = parts[15];
boolean sesame = false; boolean sesame = false;
if (allergens != "") { if (allergens != "") {
sesame = true; sesame = true;
} }
allergens = parts[19]; allergens = parts[16];
boolean soy = false; boolean soy = false;
if (allergens != "") { if (allergens != "") {
soy = true; soy = true;
} }
allergens = parts[20]; allergens = parts[17];
boolean molluscs = false; boolean molluscs = false;
if (allergens != "") { if (allergens != "") {
molluscs = true; molluscs = true;
} }
String additives = parts[21]; String additives = parts[18];
boolean antioxidant = false; boolean antioxidant = false;
if (additives != "") { if (additives != "") {
antioxidant = true; antioxidant = true;
} }
additives = parts[22]; additives = parts[19];
boolean artificialColours = false; boolean artificialColours = false;
if (additives != "") { if (additives != "") {
artificialColours = true; artificialColours = true;
} }
additives = parts[23]; additives = parts[20];
boolean flavourEnhancer = false; boolean flavourEnhancer = false;
if (additives != "") { if (additives != "") {
flavourEnhancer = true; flavourEnhancer = true;
} }
additives = parts[24]; additives = parts[21];
boolean preservatives = false; boolean preservatives = false;
if (additives != "") { if (additives != "") {
preservatives = true; preservatives = true;
} }
additives = parts[25]; additives = parts[22];
boolean nitrate = false; boolean nitrate = false;
if (additives != "") { if (additives != "") {
nitrate = true; nitrate = true;
} }
additives = parts[26]; additives = parts[23];
boolean picklingSalt = false; boolean picklingSalt = false;
if (additives != "") { if (additives != "") {
picklingSalt = true; picklingSalt = true;
} }
additives = parts[27]; additives = parts[24];
boolean phosphate = false; boolean phosphate = false;
if (additives != "") { if (additives != "") {
phosphate = true; phosphate = true;
} }
additives = parts[28]; additives = parts[25];
boolean artificialSweetener = false; boolean artificialSweetener = false;
if (additives != "") { if (additives != "") {
artificialSweetener = true; artificialSweetener = true;
} }
menueList.add(new Menue(date, dish, sideDish, typ, desertV, desert, eggs, peanuts, fish, grains, menueList.add(new Menue(date, dish, sideDish, typ, eggs, peanuts, fish, grains,
crustaceans, lupines, milk, nuts, sulfurDioxideAndSulfite, celeriac, mustards, sesame, crustaceans, lupines, milk, nuts, sulfurDioxideAndSulfite, celeriac, mustards, sesame,
soy, molluscs, antioxidant, artificialColours, flavourEnhancer, preservatives, nitrate, soy, molluscs, antioxidant, artificialColours, flavourEnhancer, preservatives, nitrate,
picklingSalt, phosphate, artificialSweetener)); picklingSalt, artificialSweetener, phosphate));
} }
return menueList; return menueList;
} }
@ -185,11 +188,12 @@ public class Data {
/** /**
* readOrder() is a method to split order.txt into lines and save them in an arraylist * readOrder() is a method to split order.txt into lines and save them in an arraylist
*
* @return Arraylist orderlist * @return Arraylist orderlist
* @author Madeleine Vigier, Sabine Gubitz * @author Madeleine Vigier, Sabine Gubitz
* @version 1.2 * @version 1.2
*/ */
public ArrayList<Order> readOrder(){ public ArrayList<Order> readOrder() {
ArrayList<String> orderList = new ArrayList<>(); ArrayList<String> orderList = new ArrayList<>();
List<String> rows = getRows(); List<String> rows = getRows();
@ -217,10 +221,11 @@ public class Data {
/** /**
* The method writeData writes the data of a List into a txt file. * 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 pathWrite determines the filename of the file that will be written
* @param listToWrite determines which ArrayList is to be used for writing the file * @param listToWrite determines which ArrayList is to be used for writing the file
*/ */
public void writeData(String pathWrite, ArrayList<String> listToWrite){ public void writeData(String pathWrite, ArrayList<String> listToWrite) {
if (pathWrite.equals("users.txt")) { if (pathWrite.equals("users.txt")) {
} else if (pathWrite.equals("orders.txt")) { } else if (pathWrite.equals("orders.txt")) {
@ -230,6 +235,7 @@ public class Data {
/** /**
* The method gets the rows by reading all lines of the path * The method gets the rows by reading all lines of the path
*
* @return ArrayList rows * @return ArrayList rows
* @author Madeleine Vigier * @author Madeleine Vigier
* @version 1.0 * @version 1.0