int numberOfSquares = 10;
Bed bed = new Bed(numberOfSquares);
// Or with a given rotation period. Default is 3 years
int rotationPeriodInYears = 4;
Bed bed = new Bed(numberOfSquares, rotationPeriodInYears);
int numOfSquares = bed.getNumberOfSquares();
Since we're using the square foot gardening method size should be 16 divided by how many of that crop we can sow in a square. For example, square foot gardening says we can only sow 1 tomato in a square foot so the size would be 16 / 1 which equals 16.
String name = "tomato";
String family = "nightshade";
int daysToHarvest = 60;
int size = 16;
Crop tomato = new Crop(name, family, daysToHarvest, size);
int squareToSow = 0;
// Sow now
bed.sow(squareToSow, tomato);
// Or with a given sowing date
LocalDate sowingDate = LocalDate.now().plusDays(10);
bed.sow(squareToSow, tomato, sowingDate);
Note: Sowing date will only exist if a crop has been sown
// Directly from the crop
LocalDate sowingDate = tomato.getSowingDate();
// or from the crops sown in the bed
List<Crop> sownCrops = bed.getSownCrops(squareToSow);
sownCrops.forEach(crop -> System.out.println(crop.getSowingDate()));
Note: Harvest date will only exist if a crop has been sown
// Directly from the crop
LocalDate harvestDate = tomato.getHarvestDate();
// or from the crops sown in the bed
List<Crop> sownCrops = bed.getSownCrops(squareToSow);
sownCrops.forEach(crop -> System.out.println(crop.getHarvestDate()));
This is useful since we're using the square foot gardening method and there are a limited number of crops we can plant per square foot.
int square = 0;
boolean canSow = bed.hasSpaceToSow(square, crop);
Note: Harvested date will only exist if a crop has been harvested
// Harvest now
bed.harvest(tomato);
// or at a given harvest date
LocalDate harvestDate = LocalDate.now().minusDays(10);
bed.harvest(tomato, harvestDate);
LocalDate harvestedDate = tomato.getHarvestedDate();
A crop will be in the history of a square after it has been harvested. This is useful knowledge for crop rotation. History is sorted oldest harvested crop first.
List<Crop> history = bed.getHistory(square);
Return true if the rotation period has passed since the last harvest of this crop's family.
String cropFamily = "nightshade";
boolean isPastRotationPeriod = bed.isPastRotationPeriodFor(cropFamily);
Returns the end date of the current rotation period for a given crop family. If there is no history for a given crop family then null is returned.
LocalDate rotationEndDate = bed.getRotationEndDateFor(cropFamily);
We may want to remove a crop from sown crops or history
bed.remove(crop);