From 007fc81b2208ebd49ad911bfb9bb94294189856f Mon Sep 17 00:00:00 2001 From: schrom01 Date: Mon, 31 Oct 2022 13:47:17 +0100 Subject: [PATCH] added Method planTasksForCrop --- .../taskList/TaskListModel.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/zhaw/gartenverwaltung/taskList/TaskListModel.java b/src/main/java/ch/zhaw/gartenverwaltung/taskList/TaskListModel.java index 7e158c4..7525886 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/taskList/TaskListModel.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/taskList/TaskListModel.java @@ -1,7 +1,12 @@ package ch.zhaw.gartenverwaltung.taskList; +import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException; import ch.zhaw.gartenverwaltung.io.JsonTaskDatabase; +import ch.zhaw.gartenverwaltung.io.PlantDatabase; import ch.zhaw.gartenverwaltung.io.TaskDatabase; +import ch.zhaw.gartenverwaltung.types.Crop; +import ch.zhaw.gartenverwaltung.types.HardinessZone; +import ch.zhaw.gartenverwaltung.types.Plant; import ch.zhaw.gartenverwaltung.types.Task; import java.io.IOException; @@ -12,23 +17,30 @@ import java.util.stream.Collectors; public class TaskListModel { private TaskDatabase taskDatabase; + private PlantDatabase plantDatabase; static final Comparator sortByStartDate = Comparator.comparing(Task::getStartDate); - - public TaskListModel(){ taskDatabase = new JsonTaskDatabase(); } - public TaskListModel(TaskDatabase taskDatabase) { + public TaskListModel(TaskDatabase taskDatabase, PlantDatabase plantDatabase) { this.taskDatabase = taskDatabase; + this.plantDatabase = plantDatabase; } public void addTask(Task task) throws IOException { taskDatabase.saveTask(task); } + public void planTasksForCrop(Crop crop) throws HardinessZoneNotSetException, IOException { + Plant plant = plantDatabase.getPlantById(HardinessZone.ZONE_8A, crop.getPlantId()).orElseThrow(); + // TODO new exception + // TODO HArdiness Zone + return; + } + public void removeTask(Task task) throws IOException { taskDatabase.removeTask(task); }