From 97686d48ca5fe9806fa7b160c812d67f50ea1bc0 Mon Sep 17 00:00:00 2001 From: pbd2h21avi Date: Thu, 15 Dec 2022 19:38:24 +0100 Subject: [PATCH] menue methode angepasst --- src/Data.java | 118 ++++++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 56 deletions(-) diff --git a/src/Data.java b/src/Data.java index 2add68f..fbc45cb 100644 --- a/src/Data.java +++ b/src/Data.java @@ -7,6 +7,7 @@ import java.util.List; /** * Data is a class to edit files. + * * @author Madeleine Vigier * @version 1.3 */ @@ -16,13 +17,15 @@ public class Data { 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 readUser(){ + public ArrayList readUser() { List rows = getRows(); ArrayList userList = new ArrayList<>(); @@ -35,149 +38,149 @@ public class Data { String phonenumber = parts[3]; String nameChildren = parts[4]; 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; - + } /** * 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 readMenue(){ - ArrayList menueList = new ArrayList<>(); - List rows = getRows(); + public ArrayList readMenue() { + List rows = getRows(); + ArrayList menueList = new ArrayList<>(); for (String row : rows) { String[] parts = row.split(";"); - String date = parts[1]; - String dish = parts[2]; - String sideDish = parts[3]; - String typ = parts[4]; - String desertV = parts[5]; - String desert = parts[6]; - String allergens = parts[7]; + String date = parts[0]; + String dish = parts[1]; + String sideDish = parts[2]; + String typ = parts[3]; + String allergens = parts[4]; boolean eggs = false; if (allergens != "") { eggs = true; + } - allergens = parts[8]; + allergens = parts[5]; boolean peanuts = false; if (allergens != "") { peanuts = true; } - allergens = parts[9]; + allergens = parts[6]; boolean fish = false; if (allergens != "") { fish = true; } - allergens = parts[10]; + allergens = parts[7]; boolean grains = false; if (allergens != "") { grains = true; } - allergens = parts[11]; + allergens = parts[8]; boolean crustaceans = false; if (allergens != "") { crustaceans = true; } - allergens = parts[12]; + allergens = parts[9]; boolean lupines = false; if (allergens != "") { lupines = true; } - allergens = parts[13]; + allergens = parts[10]; boolean milk = false; if (allergens != "") { milk = true; } - allergens = parts[14]; + allergens = parts[11]; boolean nuts = false; if (allergens != "") { nuts = true; } - allergens = parts[15]; + allergens = parts[12]; boolean sulfurDioxideAndSulfite = false; if (allergens != "") { sulfurDioxideAndSulfite = true; } - allergens = parts[16]; + allergens = parts[13]; boolean celeriac = false; if (allergens != "") { celeriac = true; } - allergens = parts[17]; + allergens = parts[14]; boolean mustards = false; if (allergens != "") { mustards = true; } - allergens = parts[18]; + allergens = parts[15]; boolean sesame = false; if (allergens != "") { sesame = true; } - allergens = parts[19]; + allergens = parts[16]; boolean soy = false; if (allergens != "") { soy = true; } - allergens = parts[20]; + allergens = parts[17]; boolean molluscs = false; if (allergens != "") { molluscs = true; } - String additives = parts[21]; + String additives = parts[18]; boolean antioxidant = false; if (additives != "") { antioxidant = true; } - additives = parts[22]; + additives = parts[19]; boolean artificialColours = false; if (additives != "") { artificialColours = true; } - additives = parts[23]; + additives = parts[20]; boolean flavourEnhancer = false; if (additives != "") { flavourEnhancer = true; } - additives = parts[24]; + additives = parts[21]; boolean preservatives = false; if (additives != "") { preservatives = true; } - additives = parts[25]; + additives = parts[22]; boolean nitrate = false; if (additives != "") { nitrate = true; } - additives = parts[26]; + additives = parts[23]; boolean picklingSalt = false; if (additives != "") { picklingSalt = true; } - additives = parts[27]; + additives = parts[24]; boolean phosphate = false; if (additives != "") { phosphate = true; } - additives = parts[28]; + additives = parts[25]; boolean artificialSweetener = false; if (additives != "") { 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, soy, molluscs, antioxidant, artificialColours, flavourEnhancer, preservatives, nitrate, - picklingSalt, phosphate, artificialSweetener)); + picklingSalt, artificialSweetener, phosphate)); } return menueList; } @@ -185,42 +188,44 @@ public class Data { /** * 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 readOrder(){ + public ArrayList readOrder() { ArrayList orderList = new ArrayList<>(); List rows = getRows(); - for (String row : rows) { - String[] parts = row.split(";"); + 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 + 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 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 listToWrite){ + public void writeData(String pathWrite, ArrayList listToWrite) { if (pathWrite.equals("users.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 + * * @return ArrayList rows * @author Madeleine Vigier * @version 1.0