Code abgenommen

This commit is contained in:
Sabine Gubitz 2022-12-14 13:17:46 +01:00
parent 48d3f5b08b
commit 87b8a566f1
3 changed files with 121 additions and 19 deletions

View File

@ -18,9 +18,9 @@ public class Data {
}
/**
* load() is a methode to split a file into lines, save lines in a arraylist
* readData() is a method to split a file into lines and save them in an arraylist
* @return Arraylist userlist
* @author Madeleine Vigier
* @author Madeleine Vigier, Sabine Gubitz
* @version 1.1
*/
public ArrayList<User> readData() {
@ -28,24 +28,124 @@ public class Data {
try {
List<String> rows = Files.readAllLines(path);
//muss noch angepasst werden
if (pathRead.equals("menue.txt")) {
//Object class Meal is still missing and needs to be added
if (pathRead.equals("menue.csv")) {
ArrayList<String> menueList = new ArrayList<>();
//Booleans for allergens
boolean eggs = false, peanuts = false, fish = false, grains = false, crustaceans = false,
lupines = false, milk = false, nuts = false, sulfurDioxideAndSulfite = false, celeriac = false,
mustards = false, sesame = false, soy = false, molluscs = false;
//Booleans for additives
boolean antioxidant = false, artificialColours = false, flavourEnhancer = false, preservatives = false,
nitrate = false, picklingSalt = false, phosphate = false, artificialSweetener = false;
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);
String dish = parts[2];
String sideDish = parts[3];
String typ = parts[4];
String desertV = parts[5];
String desert = parts[6];
String allergens = parts[7];
if ( allergens != "") {
eggs = true;
}
allergens = parts[8];
if ( allergens != "") {
peanuts = true;
}
allergens = parts[9];
if ( allergens != "") {
fish = true;
}
allergens = parts[10];
if ( allergens != "") {
grains = true;
}
allergens = parts[11];
if ( allergens != "") {
crustaceans = true;
}
allergens = parts[12];
if ( allergens != "") {
lupines = true;
}
allergens = parts[13];
if ( allergens != "") {
milk = true;
}
allergens = parts[14];
if ( allergens != "") {
nuts = true;
}
allergens = parts[15];
if ( allergens != "") {
sulfurDioxideAndSulfite = true;
}
allergens = parts[16];
if ( allergens != "") {
celeriac = true;
}
allergens = parts[17];
if ( allergens != "") {
mustards = true;
}
allergens = parts[18];
if ( allergens != "") {
sesame = true;
}
allergens = parts[19];
if ( allergens != "") {
soy = true;
}
allergens = parts[20];
if ( allergens != "") {
molluscs = true;
}
String additives = parts[21];
if ( additives != "") {
antioxidant = true;
}
additives = parts[22];
if ( additives != "") {
artificialColours = true;
}
additives = parts[23];
if ( additives != "") {
flavourEnhancer = true;
}
additives = parts[24];
if ( additives != "") {
preservatives = true;
}
additives = parts[25];
if ( additives != "") {
nitrate = true;
}
additives = parts[26];
if ( additives != "") {
picklingSalt = true;
}
additives = parts[27];
if ( additives != "") {
phosphate = true;
}
additives = parts[28];
if ( additives != "") {
artificialSweetener = true;
}
//menueList.add(new Meal(date, dish, sideDish, typ, desertV, desert, eggs, peanuts, fish, grains,
// crustaceans, lupines, milk, nuts, sulfurDioxideAndSulfite, celeriac, mustards, sesame,
// soy, molluscs, antioxidant, artificialColours, flavourEnhancer, preservatives, nitrate,
// picklingSalt, phosphate, artificialSweetener));
}
return null;//menueList;
//ist angepasst
} else if (pathRead.equals("users.txt")){
ArrayList<User> userList = new ArrayList<>();
@ -61,7 +161,7 @@ public class Data {
userList.add(new User(nameParent1,nameParent2,billAddress,phonenumber,nameChildren,password));
}
return userList;
//muss noch angepasst werden
//Object class Order is still missing and needs to be added
} else if (pathRead.equals("orders.txt")) {
ArrayList<String> orderList = new ArrayList<>();
@ -75,10 +175,12 @@ public class Data {
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];
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

View File

@ -2,7 +2,7 @@ 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) {

View File

@ -1,5 +1,5 @@
/**
* User class creates users
* User class creates User Objects
* @author Madeleine Vigier
* @version 1.1
*/