#23 bugfix adjust task

This commit is contained in:
Gian-Andrea Hutter 2022-12-04 16:32:30 +01:00
parent 5e42cae290
commit a29066ed05
2 changed files with 7 additions and 9 deletions

View File

@ -16,7 +16,7 @@ public class WeatherGradenTaskPlanner {
private final PlantList plantList;
private final CropList cropList;
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) {
this.taskList = taskList;
@ -31,7 +31,7 @@ public class WeatherGradenTaskPlanner {
}
private void getSevereWeatherEvents() throws IOException {
SevereWeather actualWeather = weatherService.causeSevereWeather(0);
SevereWeather actualWeather = weatherService.causeSevereWeather(1);
if (SevereWeather.HAIL.equals(actualWeather)) {
createPreHail();
} else if (SevereWeather.FROST.equals(actualWeather)) {
@ -50,8 +50,7 @@ public class WeatherGradenTaskPlanner {
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",
dateSevereWeather.minusDays(1L));
preHailTask.withId(Long.MAX_VALUE);
dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L));
taskList.saveTask(preHailTask);
}
@ -59,16 +58,14 @@ public class WeatherGradenTaskPlanner {
public void createPreFrost() throws IOException {
Task preFrostTask = new Task("Frost",
"The temperatur falls below zero degrees, cover especially the root with wool",
dateSevereWeather.minusDays(1L));
preFrostTask.withId(Long.MAX_VALUE);
dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L));
taskList.saveTask(preFrostTask);
}
public void createPreSnow() throws IOException {
Task preSnowTask = new Task("Snow",
"The weather brings little snowfall. Cover your crops",
dateSevereWeather.minusDays(1L));
preSnowTask.withId(Long.MAX_VALUE);
dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L));
taskList.saveTask(preSnowTask);
}

View File

@ -44,10 +44,11 @@ public class Task {
/**
* 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.description = description;
this.startDate = startDate;
this.endDate = endDate;
}
public Task(String name, String description, LocalDate startDate, LocalDate endDate, int interval, long cropId) {