add: createFood
This commit is contained in:
		| @@ -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<Allergy> 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(""); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Johannes Kantz
					Johannes Kantz