finished tests for Plant, added fix for Plant
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user