From 16675c4cf8843666afe7bde4b2119f29c1e6a86e Mon Sep 17 00:00:00 2001 From: Kevin Pfannenstiel Date: Mon, 30 Jan 2023 14:33:30 +0100 Subject: [PATCH] View angepasst (Madeleine) --- .../java/com/example/vpr_javafx/Data.java | 1 - .../example/vpr_javafx/HelloApplication.java | 7 +- .../example/vpr_javafx/HelloController.java | 179 ++++++++------- .../java/com/example/vpr_javafx/Menu.java | 12 + .../java/com/example/vpr_javafx/Order.java | 5 + .../java/com/example/vpr_javafx/User.java | 4 + .../example/vpr_javafx/MenuOverview-view.fxml | 207 ++++++++++++++++++ .../classes/com/example/vpr_javafx/Data.class | Bin 9209 -> 9209 bytes .../example/vpr_javafx/HelloApplication.class | Bin 1461 -> 1532 bytes .../example/vpr_javafx/HelloController.class | Bin 5362 -> 5101 bytes .../classes/com/example/vpr_javafx/Menu.class | Bin 1210 -> 1828 bytes .../example/vpr_javafx/MenuOverview-view.fxml | 207 ++++++++++++++++++ .../com/example/vpr_javafx/Order.class | Bin 577 -> 1196 bytes .../classes/com/example/vpr_javafx/User.class | Bin 1061 -> 1705 bytes user.txt | 4 +- 15 files changed, 541 insertions(+), 85 deletions(-) create mode 100644 src/main/resources/com/example/vpr_javafx/MenuOverview-view.fxml create mode 100644 target/classes/com/example/vpr_javafx/MenuOverview-view.fxml diff --git a/src/main/java/com/example/vpr_javafx/Data.java b/src/main/java/com/example/vpr_javafx/Data.java index 3817f70..f8f7815 100644 --- a/src/main/java/com/example/vpr_javafx/Data.java +++ b/src/main/java/com/example/vpr_javafx/Data.java @@ -307,7 +307,6 @@ public class Data { } - /** * The method changes the orders.txt file by removing canceled orders * diff --git a/src/main/java/com/example/vpr_javafx/HelloApplication.java b/src/main/java/com/example/vpr_javafx/HelloApplication.java index 5be1453..a13f2b2 100644 --- a/src/main/java/com/example/vpr_javafx/HelloApplication.java +++ b/src/main/java/com/example/vpr_javafx/HelloApplication.java @@ -10,13 +10,14 @@ import java.io.IOException; public class HelloApplication extends Application { @Override public void start(Stage stage) throws IOException { - FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml")); - Scene scene = new Scene(fxmlLoader.load()); - stage.setTitle("Essen Bestellen"); + FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("MenuOverview-view.fxml")); + Scene scene = new Scene(fxmlLoader.load(),1000, 800); + stage.setTitle("Mittagsbestellung"); stage.setScene(scene); stage.show(); HelloController controller = fxmlLoader.getController(); controller.FillLabels(); + controller.writeAllergene(); } public static void main(String[] args) { diff --git a/src/main/java/com/example/vpr_javafx/HelloController.java b/src/main/java/com/example/vpr_javafx/HelloController.java index c7e06b4..4e911ba 100644 --- a/src/main/java/com/example/vpr_javafx/HelloController.java +++ b/src/main/java/com/example/vpr_javafx/HelloController.java @@ -64,6 +64,8 @@ public class HelloController { private Stage stage; private Scene scene; + @FXML + private Label allergene; @FXML protected void OnSignInButton(ActionEvent event) throws IOException @@ -81,98 +83,117 @@ public class HelloController { { if (users.get(phoneNumber).equals(password)) { - Parent root = FXMLLoader.load(getClass().getResource("MenuSelect-view.fxml")); - stage = (Stage)((Node)event.getSource()).getScene().getWindow(); - scene = new Scene(root); - stage.setScene(scene); - stage.show(); - FillLabels(); + } } -} + } @FXML protected void FillLabels() { try { - List menu = Files.readAllLines(Paths.get("menue.txt")); + List menu = Files.readAllLines(Paths.get("menue.txt")); - for (int i = 0; i < menu.size(); i++) - { - String[] parts = menu.get(i).split(";"); + for (int i = 0; i < menu.size(); i++) + { + String[] parts = menu.get(i).split(";"); - String dish = parts[1]; - String sideDish = parts[2]; + String dish = parts[1]; + String sideDish = parts[2]; - String dayMenu = dish+"\n"+sideDish; + String dayMenu = dish+"\n"+sideDish; - switch (i) { - case 0: - lMonH1.setText(dayMenu); - break; - case 1: - lMonD1.setText(dayMenu); - break; - case 2: - lMonH2.setText(dayMenu); - break; - case 3: - lMonD2.setText(dayMenu); - break; - case 4: - lTueH1.setText(dayMenu); - break; - case 5: - lTueD1.setText(dayMenu); - break; - case 6: - lTueH2.setText(dayMenu); - break; - case 7: - lTueD2.setText(dayMenu); - break; - case 8: - lWednH1.setText(dayMenu); - break; - case 9: - lWednD1.setText(dayMenu); - break; - case 10: - lWednH2.setText(dayMenu); - break; - case 11: - lWednD2.setText(dayMenu); - break; - case 12: - lThurH1.setText(dayMenu); - break; - case 13: - lThurD1.setText(dayMenu); - break; - case 14: - lThurH2.setText(dayMenu); - break; - case 15: - lThurD2.setText(dayMenu); - break; - case 16: - lFriH1.setText(dayMenu); - break; - case 17: - lFriD1.setText(dayMenu); - break; - case 18: - lFriH2.setText(dayMenu); - break; - case 19: - lFriD2.setText(dayMenu); - break; + switch (i) { + case 0: + lMonH1.setText(dayMenu); + break; + case 1: + lMonD1.setText(dayMenu); + break; + case 2: + lMonH2.setText(dayMenu); + break; + case 3: + lMonD2.setText(dayMenu); + break; + case 4: + lTueH1.setText(dayMenu); + break; + case 5: + lTueD1.setText(dayMenu); + break; + case 6: + lTueH2.setText(dayMenu); + break; + case 7: + lTueD2.setText(dayMenu); + break; + case 8: + lWednH1.setText(dayMenu); + break; + case 9: + lWednD1.setText(dayMenu); + break; + case 10: + lWednH2.setText(dayMenu); + break; + case 11: + lWednD2.setText(dayMenu); + break; + case 12: + lThurH1.setText(dayMenu); + break; + case 13: + lThurD1.setText(dayMenu); + break; + case 14: + lThurH2.setText(dayMenu); + break; + case 15: + lThurD2.setText(dayMenu); + break; + case 16: + lFriH1.setText(dayMenu); + break; + case 17: + lFriD1.setText(dayMenu); + break; + case 18: + lFriH2.setText(dayMenu); + break; + case 19: + lFriD2.setText(dayMenu); + break; + } } } - } - catch (IOException e) { - e.printStackTrace(); - } + catch (IOException e) { + e.printStackTrace(); + } } + + /** + * writeAllergene() is a method to format and set allergene + * @author Madeleine Vigier + */ + @FXML + protected void writeAllergene() { + allergene.setText("a: Eier; b: Soja,\n" + + "c: Milch; d: Erdnüsse;\n" + + "e: Weichtiere; f: Krebstiere;\n" + + "g: Getreide; h: Senf; i: Sesam;\n" + + "j: Schwefeldioxid und Sulfit;\n" + + "k: Nüsse; l: Sellerie;\n" + + "m: Fische; n: Lupinen\n\n" + + "1: Nitrit-Pökelsalz\n" + + "2:Phosphat\n" + + "3: Nitrat\n" + + "4: Antioxidationsmittel\n" + + "5: Farbstoff\n" + + "6: Geschmacksverstärker;\n" + + "7: Süßungsmittel;\n" + + "8: Konservierungsstoff"); + } + } \ No newline at end of file diff --git a/src/main/java/com/example/vpr_javafx/Menu.java b/src/main/java/com/example/vpr_javafx/Menu.java index aa6edf2..5fe5db1 100644 --- a/src/main/java/com/example/vpr_javafx/Menu.java +++ b/src/main/java/com/example/vpr_javafx/Menu.java @@ -15,6 +15,7 @@ public class Menu { String type; List ingredients; + /** * constructor * @@ -57,5 +58,16 @@ public class Menu { } } + + /** + * 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, Felix Wöstemeyer + */ + @Override + public String toString() { + return date+";"+dish+";"+sideDish+";"+type+";"+ingredients; + } } diff --git a/src/main/java/com/example/vpr_javafx/Order.java b/src/main/java/com/example/vpr_javafx/Order.java index 9393797..1775a2e 100644 --- a/src/main/java/com/example/vpr_javafx/Order.java +++ b/src/main/java/com/example/vpr_javafx/Order.java @@ -20,4 +20,9 @@ public class Order { this.mealtype = mealtype; this.desserttype = desserttype; } + + @Override + public String toString(){ + return date+";"+user+";"+mealtype+";"+desserttype; + } } diff --git a/src/main/java/com/example/vpr_javafx/User.java b/src/main/java/com/example/vpr_javafx/User.java index e321a06..50da10a 100644 --- a/src/main/java/com/example/vpr_javafx/User.java +++ b/src/main/java/com/example/vpr_javafx/User.java @@ -80,4 +80,8 @@ public class User { * @return a String with nameParent1, nameparent2, billAdress, phonenumber, nameChildren, password * @author Madeleine Vigier */ + @Override + public String toString() { + return nameParent1 + ";" + nameParent2 + ";" + billAddress + ";" + phoneNumber + ";" + nameChildren + ";" + password; + } } diff --git a/src/main/resources/com/example/vpr_javafx/MenuOverview-view.fxml b/src/main/resources/com/example/vpr_javafx/MenuOverview-view.fxml new file mode 100644 index 0000000..9b6e622 --- /dev/null +++ b/src/main/resources/com/example/vpr_javafx/MenuOverview-view.fxml @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +