Korrektur der Syntax und einhaltliche toString für das Speichern der Daten.

This commit is contained in:
Felix Wöstemeyer 2023-01-17 15:43:56 +01:00
parent d858ff8f8d
commit d2f9ef49c9
4 changed files with 27 additions and 28 deletions

View File

@ -188,9 +188,9 @@ public class Data {
String date = parts[0]; String date = parts[0];
String user = parts[1]; String user = parts[1];
String mealtyp = parts[3]; String mealtype = parts[3];
String deserttyp = parts[5]; String deserttype = parts[5];
orderList.add(new Order(date, user, mealtyp, deserttyp)); orderList.add(new Order(date, user, mealtype, deserttype));
} }
return null;//orderList return null;//orderList
@ -207,6 +207,8 @@ public class Data {
} else if (pathWrite.equals("orders.txt")) { } else if (pathWrite.equals("orders.txt")) {
} else if (pathWrite.equals("menue.txt")){
} }
} }

View File

@ -10,7 +10,7 @@ public class Menu {
String date; String date;
String dish; String dish;
String sideDish; String sideDish;
String typ; String type;
List<String> ingredients; List<String> ingredients;
@ -20,14 +20,14 @@ public class Menu {
* @param date date of meal * @param date date of meal
* @param dish meal * @param dish meal
* @param sideDish side dish * @param sideDish side dish
* @param typ vegan, vegetarian or meat * @param type vegan, vegetarian or meat
* @param ingredients list of ingredients * @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.date = date;
this.dish = dish; this.dish = dish;
this.sideDish = sideDish; this.sideDish = sideDish;
this.typ = typ; this.type = type;
this.ingredients = ingredients; this.ingredients = ingredients;
} }
@ -47,26 +47,25 @@ public class Menu {
* @return typ e.g. Vegan * @return typ e.g. Vegan
* @author Madeleine Vigier * @author Madeleine Vigier
*/ */
public String getTyp() { public String getType() {
if (typ.contains("DessertV") || typ.contains("Dessert")) { if (type.contains("DessertV") || type.contains("Dessert")) {
return ""; return "";
} else { } 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 * @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 @Override
public String toString() { public String toString() {
return dish + "\n" + sideDish return date+";"+dish+";"+sideDish+";"+type+";"+ingredients;
+ "\n" + ingredients.toString().replace("[", "").replace("]", "") + "\n" + getTyp() + "\n";
} }
} }

View File

@ -8,14 +8,19 @@
public class Order { public class Order {
String date; //date for the meal, not the day it was ordered String date; //date for the meal, not the day it was ordered
String user; //phone number of the user account String user; //phone number of the user account
String mealtyp; //meat, vegi or vegan String mealtype; //meat, vegi or vegan
String deserttyp; //desert or vegan desert String desserttype; //desert or vegan desert
Order (String date, String user, String mealtyp, String deserttyp) Order (String date, String user, String mealtype, String desserttype)
{ {
this.date = date; this.date = date;
this.user = user; this.user = user;
this.mealtyp = mealtyp; this.mealtype = mealtype;
this.deserttyp = deserttyp; this.desserttype = desserttype;
}
@Override
public String toString(){
return date+";"+user+";"+mealtype+";"+desserttype;
} }
} }

View File

@ -19,7 +19,7 @@ public class User {
* @param nameParent2 name of the second parent of the child * @param nameParent2 name of the second parent of the child
* @param billAddress the address the bill should be sent to * @param billAddress the address the bill should be sent to
* @param phoneNumber phonenumber of one of the parents and also the username * @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 * @param password password of the user
* @author Madeleine Vigier * @author Madeleine Vigier
*/ */
@ -80,13 +80,6 @@ public class User {
*/ */
@Override @Override
public String toString() { public String toString() {
return "User{" + return nameParent1 + ";" + nameParent2 + ";" + billAddress + ";" + phoneNumber + ";" + nameChildren + ";" + password;
"nameParent1='" + nameParent1 + '\'' +
", nameParent2='" + nameParent2 + '\'' +
", billAddress='" + billAddress + '\'' +
", phonenumber='" + phoneNumber + '\'' +
", nameChildren='" + nameChildren + '\'' +
", password='" + password + '\'' +
'}';
} }
} }