From 5ee0288736dc1bd5a33ee4d2fd5b210c9df1049f Mon Sep 17 00:00:00 2001 From: Johannes Kantz <67144859+JohannesKantz@users.noreply.github.com> Date: Wed, 1 Feb 2023 07:21:37 +0100 Subject: [PATCH 1/5] add: database.db to gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5ff6309..1165112 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,6 @@ build/ .vscode/ ### Mac OS ### -.DS_Store \ No newline at end of file +.DS_Store + +/database.db \ No newline at end of file From f71aba35055e7206f941598ec98a43f5b55faa73 Mon Sep 17 00:00:00 2001 From: Johannes Kantz <67144859+JohannesKantz@users.noreply.github.com> Date: Wed, 1 Feb 2023 07:21:59 +0100 Subject: [PATCH 2/5] add: createFood --- .../CreateFoodController.java | 71 +++++++ .../createFood-view.fxml | 195 +++++++++--------- 2 files changed, 171 insertions(+), 95 deletions(-) create mode 100644 src/main/java/com/bib/essensbestellungsverwaltung/CreateFoodController.java diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/CreateFoodController.java b/src/main/java/com/bib/essensbestellungsverwaltung/CreateFoodController.java new file mode 100644 index 0000000..7370fdf --- /dev/null +++ b/src/main/java/com/bib/essensbestellungsverwaltung/CreateFoodController.java @@ -0,0 +1,71 @@ +package com.bib.essensbestellungsverwaltung; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.RadioButton; +import javafx.scene.control.TextArea; +import javafx.scene.control.TextField; +import javafx.scene.text.Text; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class CreateFoodController { + @FXML + public TextField name; + @FXML + public TextArea description; + @FXML + public RadioButton isHauptgerichtRadio; + @FXML + public RadioButton isDessertRadio; + @FXML + public RadioButton isVegetarischRadio; + @FXML + public RadioButton isVeganRadio; + @FXML + public RadioButton isFleischRadio; + @FXML + public TextArea allergienTextBox; + @FXML + public Text responseText; + + @FXML + public void onAbbrechen(ActionEvent actionEvent) { + clearInputs(); + } + + @FXML + public void onHinzufügen(ActionEvent actionEvent) { + String gerichtName = name.getText(); + String beschreibung = description.getText(); + if(!isHauptgerichtRadio.isSelected() && !isDessertRadio.isSelected()){ + // art auswähelen + } + boolean isNachtisch = !isHauptgerichtRadio.isSelected(); + if(!isVegetarischRadio.isSelected() && !isVeganRadio.isSelected() && isFleischRadio.isSelected()){ + // Typ auswählen + } + int ft = isVeganRadio.isSelected() ? 1 : isVeganRadio.isSelected() ? 2 : 3; + FoodType foodType = new FoodType(ft, "Vegan"); + List allergies = new ArrayList<>(); + // TODO: allergien hinzufügen + + long id = FoodMgr.createFood(new Food(gerichtName, beschreibung, isNachtisch, foodType, allergies)); + System.out.println("Food created with id: " + id); + responseText.setText("New Food Created"); + clearInputs(); + } + + private void clearInputs(){ + name.setText(""); + description.setText(""); + isHauptgerichtRadio.setSelected(false); + isDessertRadio.setSelected(false); + isVeganRadio.setSelected(false); + isVegetarischRadio.setSelected(false); + isFleischRadio.setSelected(false); + allergienTextBox.setText(""); + } +} diff --git a/src/main/resources/com/bib/essensbestellungsverwaltung/createFood-view.fxml b/src/main/resources/com/bib/essensbestellungsverwaltung/createFood-view.fxml index 018c80d..1e81cbf 100644 --- a/src/main/resources/com/bib/essensbestellungsverwaltung/createFood-view.fxml +++ b/src/main/resources/com/bib/essensbestellungsverwaltung/createFood-view.fxml @@ -1,102 +1,107 @@ - - - - - - - - - - + + + + - - - - - - - -