From d2f9ef49c98469f92bf503139f426b9a7aff7c6a Mon Sep 17 00:00:00 2001 From: Felix Woestemeyer Date: Tue, 17 Jan 2023 15:43:56 +0100 Subject: [PATCH] =?UTF-8?q?Korrektur=20der=20Syntax=20und=20einhaltliche?= =?UTF-8?q?=20toString=20f=C3=BCr=20das=20Speichern=20der=20Daten.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data.java | 8 +++++--- src/Menu.java | 21 ++++++++++----------- src/Order.java | 15 ++++++++++----- src/User.java | 11 ++--------- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/Data.java b/src/Data.java index 8c5a40f..8028ac5 100644 --- a/src/Data.java +++ b/src/Data.java @@ -188,9 +188,9 @@ public class Data { String date = parts[0]; String user = parts[1]; - String mealtyp = parts[3]; - String deserttyp = parts[5]; - orderList.add(new Order(date, user, mealtyp, deserttyp)); + String mealtype = parts[3]; + String deserttype = parts[5]; + orderList.add(new Order(date, user, mealtype, deserttype)); } return null;//orderList @@ -207,6 +207,8 @@ public class Data { } else if (pathWrite.equals("orders.txt")) { + } else if (pathWrite.equals("menue.txt")){ + } } diff --git a/src/Menu.java b/src/Menu.java index 71ac4f6..99276d2 100644 --- a/src/Menu.java +++ b/src/Menu.java @@ -10,7 +10,7 @@ public class Menu { String date; String dish; String sideDish; - String typ; + String type; List ingredients; @@ -20,14 +20,14 @@ public class Menu { * @param date date of meal * @param dish meal * @param sideDish side dish - * @param typ vegan, vegetarian or meat + * @param type vegan, vegetarian or meat * @param ingredients list of ingredients */ - public Menu(String date, String dish, String sideDish, String typ, List ingredients) { + public Menu(String date, String dish, String sideDish, String type, List ingredients) { this.date = date; this.dish = dish; this.sideDish = sideDish; - this.typ = typ; + this.type = type; this.ingredients = ingredients; } @@ -47,26 +47,25 @@ public class Menu { * @return typ e.g. Vegan * @author Madeleine Vigier */ - public String getTyp() { - if (typ.contains("DessertV") || typ.contains("Dessert")) { + public String getType() { + if (type.contains("DessertV") || type.contains("Dessert")) { return ""; } 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 - * @author Madeleine Vigier + * @author Madeleine Vigier, Felix Wöstemeyer */ @Override public String toString() { - return dish + "\n" + sideDish - + "\n" + ingredients.toString().replace("[", "").replace("]", "") + "\n" + getTyp() + "\n"; + return date+";"+dish+";"+sideDish+";"+type+";"+ingredients; } } diff --git a/src/Order.java b/src/Order.java index 525317a..ce80745 100644 --- a/src/Order.java +++ b/src/Order.java @@ -8,14 +8,19 @@ public class Order { String date; //date for the meal, not the day it was ordered String user; //phone number of the user account - String mealtyp; //meat, vegi or vegan - String deserttyp; //desert or vegan desert + String mealtype; //meat, vegi or vegan + 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.user = user; - this.mealtyp = mealtyp; - this.deserttyp = deserttyp; + this.mealtype = mealtype; + this.desserttype = desserttype; + } + + @Override + public String toString(){ + return date+";"+user+";"+mealtype+";"+desserttype; } } diff --git a/src/User.java b/src/User.java index a569f70..a44bea9 100644 --- a/src/User.java +++ b/src/User.java @@ -19,7 +19,7 @@ public class User { * @param nameParent2 name of the second parent of the child * @param billAddress the address the bill should be sent to * @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 * @author Madeleine Vigier */ @@ -80,13 +80,6 @@ public class User { */ @Override public String toString() { - return "User{" + - "nameParent1='" + nameParent1 + '\'' + - ", nameParent2='" + nameParent2 + '\'' + - ", billAddress='" + billAddress + '\'' + - ", phonenumber='" + phoneNumber + '\'' + - ", nameChildren='" + nameChildren + '\'' + - ", password='" + password + '\'' + - '}'; + return nameParent1 + ";" + nameParent2 + ";" + billAddress + ";" + phoneNumber + ";" + nameChildren + ";" + password; } }