-
-
Save pawelpluta/535c6cfeb09a109fb0f4915c5e7f9519 to your computer and use it in GitHub Desktop.
Article: Tell Don't Ask: Raised Bed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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