Skip to content

Instantly share code, notes, and snippets.

@pawelpluta

pawelpluta/RaisedBed.java Secret

Created Jan 28, 2021
Embed
What would you like to do?
Article: Tell Don't Ask: Raised Bed
public class RaisedBed {
private final RaisedBedId id;
private final List<Plant> plants;
public RaisedBed(RaisedBedId id, List<Plant> plants) {
this.id = id;
this.plants = plants;
}
public WateringResult waterWith(WaterValve waterValve) {
for (Plant plant : plants) {
WateringResult result = plant.waterWith(waterValve);
if (!(result instanceof WateringResult.SuccessfullyWatered)) {
return result;
}
}
return WateringResult.success();
}
// truncated other methods
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment