Merge pull request #70 from schrom01/tests_and_fixes_M3
Tests and fixes m3
This commit is contained in:
@@ -233,11 +233,11 @@ public class PlantsController {
|
||||
RadioButton radioButton = new RadioButton(season.getName());
|
||||
radioButton.setToggleGroup(seasonGroup);
|
||||
radioButton.setPadding(new Insets(0, 0, 10, 0));
|
||||
if (season.equals(Seasons.AllSEASONS)) {
|
||||
if (season.equals(Seasons.ALLSEASONS)) {
|
||||
radioButton.setSelected(true);
|
||||
}
|
||||
radioButton.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (season.equals(Seasons.AllSEASONS)) {
|
||||
if (season.equals(Seasons.ALLSEASONS)) {
|
||||
fillPlantListWithHardinessZone();
|
||||
} else {
|
||||
try {
|
||||
|
||||
@@ -96,7 +96,8 @@ public class JsonTaskList implements TaskList {
|
||||
if(taskMap.isEmpty()) {
|
||||
loadTaskListFromFile();
|
||||
}
|
||||
taskMap.values().removeIf(task -> task.getCropId() == cropId);
|
||||
taskMap.entrySet().removeIf(entry -> entry.getValue().getCropId() == cropId);
|
||||
writeTaskListToFile();
|
||||
notifySubscribers();
|
||||
}
|
||||
|
||||
|
||||
@@ -66,16 +66,16 @@ public record Plant(
|
||||
public int timeToHarvest(int group) {
|
||||
List<GrowthPhase> activeLifecycle = lifecycleForGroup(group);
|
||||
GrowthPhase sow = activeLifecycle.stream()
|
||||
.filter(growthPhase -> !growthPhase.type().equals(GrowthPhaseType.SOW))
|
||||
.filter(growthPhase -> growthPhase.type().equals(GrowthPhaseType.SOW))
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
GrowthPhase harvest = activeLifecycle.stream()
|
||||
.filter(growthPhase -> !growthPhase.type().equals(GrowthPhaseType.HARVEST))
|
||||
.filter(growthPhase -> growthPhase.type().equals(GrowthPhaseType.HARVEST))
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
|
||||
int currentYear = LocalDate.now().getYear();
|
||||
return (int) DAYS.between(harvest.startDate().atYear(currentYear), sow.startDate().atYear(currentYear));
|
||||
return (int) DAYS.between(sow.startDate().atYear(currentYear),harvest.startDate().atYear(currentYear));
|
||||
}
|
||||
|
||||
public int lifecycleGroupFromHarvestDate(LocalDate harvestDate) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package ch.zhaw.gartenverwaltung.types;
|
||||
import java.time.MonthDay;
|
||||
|
||||
public enum Seasons {
|
||||
AllSEASONS("--01-01", "--12-31", "All Seasons"),
|
||||
ALLSEASONS("--01-01", "--12-31", "All Seasons"),
|
||||
SPRING("--03-01", "--05-30", "Spring"),
|
||||
SUMMER("--06-01", "--08-30", "Summer"),
|
||||
AUTUMN("--09-01", "--11-30", "Autumn"),
|
||||
|
||||
Reference in New Issue
Block a user