Compare commits

..

2 Commits

Author SHA1 Message Date
Gian-Andrea Hutter d0c6525d7a Merge remote-tracking branch 'origin/feature_weather' into feature_weather 2022-12-04 16:32:51 +01:00
Gian-Andrea Hutter a29066ed05 #23 bugfix adjust task 2022-12-04 16:32:30 +01:00
2 changed files with 7 additions and 9 deletions

View File

@ -16,7 +16,7 @@ public class WeatherGradenTaskPlanner {
private final PlantList plantList; private final PlantList plantList;
private final CropList cropList; private final CropList cropList;
WeatherService weatherService; WeatherService weatherService;
private final LocalDate dateSevereWeather = LocalDate.of(22,12,15); private final LocalDate dateSevereWeather = LocalDate.of(2022,12,15);
public WeatherGradenTaskPlanner(TaskList taskList, PlantList plantList, CropList cropList) { public WeatherGradenTaskPlanner(TaskList taskList, PlantList plantList, CropList cropList) {
this.taskList = taskList; this.taskList = taskList;
@ -31,7 +31,7 @@ public class WeatherGradenTaskPlanner {
} }
private void getSevereWeatherEvents() throws IOException { private void getSevereWeatherEvents() throws IOException {
SevereWeather actualWeather = weatherService.causeSevereWeather(0); SevereWeather actualWeather = weatherService.causeSevereWeather(1);
if (SevereWeather.HAIL.equals(actualWeather)) { if (SevereWeather.HAIL.equals(actualWeather)) {
createPreHail(); createPreHail();
} else if (SevereWeather.FROST.equals(actualWeather)) { } else if (SevereWeather.FROST.equals(actualWeather)) {
@ -50,8 +50,7 @@ public class WeatherGradenTaskPlanner {
Task preHailTask = new Task("Hail", Task preHailTask = new Task("Hail",
"During a summer Thunderstorm it could hail heavily. THe Hail could damage the crops. To prevent damage cover the plants with a strong tarpaulin", "During a summer Thunderstorm it could hail heavily. THe Hail could damage the crops. To prevent damage cover the plants with a strong tarpaulin",
dateSevereWeather.minusDays(1L)); dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L));
preHailTask.withId(Long.MAX_VALUE);
taskList.saveTask(preHailTask); taskList.saveTask(preHailTask);
} }
@ -59,16 +58,14 @@ public class WeatherGradenTaskPlanner {
public void createPreFrost() throws IOException { public void createPreFrost() throws IOException {
Task preFrostTask = new Task("Frost", Task preFrostTask = new Task("Frost",
"The temperatur falls below zero degrees, cover especially the root with wool", "The temperatur falls below zero degrees, cover especially the root with wool",
dateSevereWeather.minusDays(1L)); dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L));
preFrostTask.withId(Long.MAX_VALUE);
taskList.saveTask(preFrostTask); taskList.saveTask(preFrostTask);
} }
public void createPreSnow() throws IOException { public void createPreSnow() throws IOException {
Task preSnowTask = new Task("Snow", Task preSnowTask = new Task("Snow",
"The weather brings little snowfall. Cover your crops", "The weather brings little snowfall. Cover your crops",
dateSevereWeather.minusDays(1L)); dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L));
preSnowTask.withId(Long.MAX_VALUE);
taskList.saveTask(preSnowTask); taskList.saveTask(preSnowTask);
} }

View File

@ -44,10 +44,11 @@ public class Task {
/** /**
* Constructor for weather events * Constructor for weather events
*/ */
public Task(String name, String description, LocalDate startDate) { public Task(String name, String description, LocalDate startDate, LocalDate endDate) {
this.name = name; this.name = name;
this.description = description; this.description = description;
this.startDate = startDate; this.startDate = startDate;
this.endDate = endDate;
} }
public Task(String name, String description, LocalDate startDate, LocalDate endDate, int interval, long cropId) { public Task(String name, String description, LocalDate startDate, LocalDate endDate, int interval, long cropId) {