Class GardenHelper

Object
GardenHelper

public class GardenHelper extends Object
  • Field Details

  • Constructor Details

    • GardenHelper

      public GardenHelper()
  • Method Details

    • go

      public void go()
      Runs the Application GardenHelper
    • addRow

      public boolean addRow(int row, int pH, String light)
      Initializes GardenRow one, two, or three.

      Implementation notes:

      • Creates a new row object based on parameters
      • Stores row object in GardenRow one, two, or three according to proper parameter
      Returns:
      true if adding row was successful, return false if unsuccessful
    • addPlant

      public boolean addPlant(String plantName, int row)
      Adds plant (based on the five options) to designated row. If plant needs meet row conditions, the plant will be added. If not, then the plant will not be added to the row.
      Returns:
      true if plant was successfully added, false if unsuccessful
    • canPlant

      public boolean canPlant(String plantName, GardenRow row)
      Checks if a particular plant is allowed to be planted where the user designates.

      Conditions for planting:

      • Row must have correct sun coverage (full sun, partial sun, or any)
      • Row must have a pH between the plant's pH range
      • At least one row must have vegetables, so if it is the third row and the other two have flowers - can't plant a flower. Also remember that if there is currently no plant in the row, GardenRow.getPlant() will throw a null pointer exception. To remedy this, make the first condition check if GardenRow.getPlant() != null
      Parameters:
      plantName - name of the pant to be planted in the entire row
      row - row to plant plants in (1, 2, or 3)
      Returns:
    • buildOptions

      public void buildOptions()
      Initializes the possible GardenPlants.
    • searchPlant

      public GardenPlant searchPlant(String plantName)
      Searches for a GardenPlant based on a plant name passed in
      Parameters:
      plantName - name of plant
      Returns:
      one of the GardenPlant options
    • searchRow

      public GardenRow searchRow(int row)
      Finds the GardenRow based on an numerical input
      Parameters:
      row - int that numerically represents the row
    • main

      public static void main(String[] args)