diff --git a/src/main/java/de/hitec/nhplus/medication/Ingredient.java b/src/main/java/de/hitec/nhplus/medication/Ingredient.java new file mode 100644 index 0000000..0ddca5a --- /dev/null +++ b/src/main/java/de/hitec/nhplus/medication/Ingredient.java @@ -0,0 +1,36 @@ +package de.hitec.nhplus.medication; + +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleStringProperty; + +public class Ingredient { + private SimpleIntegerProperty id; + private SimpleStringProperty name; + + public Ingredient(int id, String name) { + this.id = new SimpleIntegerProperty(id); + this.name = new SimpleStringProperty(name); + } + + public int getId() { + return id.get(); + } + + public SimpleIntegerProperty idProperty() { + return id; + } + + public String getName() { + return name.get(); + } + + public SimpleStringProperty nameProperty() { + return name; + } + + public void setName(String name) { + this.name.set(name); + } + + +} diff --git a/src/main/java/de/hitec/nhplus/medication/Medication.java b/src/main/java/de/hitec/nhplus/medication/Medication.java index 8ad6f9e..bf6046c 100644 --- a/src/main/java/de/hitec/nhplus/medication/Medication.java +++ b/src/main/java/de/hitec/nhplus/medication/Medication.java @@ -12,7 +12,7 @@ public class Medication { private SimpleIntegerProperty id; private final SimpleStringProperty name; private final SimpleStringProperty manufacturer; - private final SimpleListProperty ingredients; + private final SimpleListProperty ingredients; private final SimpleStringProperty possibleSideEffects; private final SimpleStringProperty administrationMethod; private final SimpleIntegerProperty currentStock; @@ -20,7 +20,7 @@ public class Medication { public Medication( String name, String manufacturer, - ObservableList ingredients, + ObservableList ingredients, String possibleSideEffects, String administrationMethod, int currentStock @@ -37,7 +37,7 @@ public class Medication { int id, String name, String manufacturer, - ObservableList ingredients, + ObservableList ingredients, String possibleSideEffects, String administrationMethod, int currentStock @@ -83,15 +83,15 @@ public class Medication { this.manufacturer.set(manufacturer); } - public ObservableList getIngredients() { + public ObservableList getIngredients() { return ingredients.get(); } - public SimpleListProperty ingredientsProperty() { + public SimpleListProperty ingredientsProperty() { return ingredients; } - public void setIngredients(ObservableList ingredients) { + public void setIngredients(ObservableList ingredients) { this.ingredients.set(ingredients); } @@ -140,6 +140,7 @@ public class Medication { .add("Manufacturer: " + this.getManufacturer()) .add("Ingredients: " + this.getIngredients() .stream() + .map(Ingredient::getName) .collect(Collectors.joining(", ", "[", "]"))) .add("Possible Side Effects: " + this.getPossibleSideEffects()) .add("Administration Method: " + this.getAdministrationMethod())