Class GardenHelper
Object
GardenHelper
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) GardenPlant
(package private) GardenPlant
(package private) GardenPlant
(package private) GardenRow
(package private) GardenPlant
(package private) GardenPlant
(package private) GardenRow
(package private) GardenRow
private final GardenView
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds plant (based on the five options) to designated row.boolean
Initializes GardenRow one, two, or three.void
Initializes the possible GardenPlants.boolean
Checks if a particular plant is allowed to be planted where the user designates.void
go()
Runs the Application GardenHelperstatic void
searchPlant
(String plantName) Searches for a GardenPlant based on a plant name passed insearchRow
(int row) Finds the GardenRow based on an numerical input
-
Field Details
-
view
-
daisy
GardenPlant daisy -
carrot
GardenPlant carrot -
rose
GardenPlant rose -
swissChard
GardenPlant swissChard -
begonia
GardenPlant begonia -
one
GardenRow one -
two
GardenRow two -
three
GardenRow three
-
-
Constructor Details
-
GardenHelper
public GardenHelper()
-
-
Method Details
-
go
public void go()Runs the Application GardenHelper -
addRow
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
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
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 ifGardenRow.getPlant()
!= null
- Parameters:
plantName
- name of the pant to be planted in the entire rowrow
- row to plant plants in (1, 2, or 3)- Returns:
-
buildOptions
public void buildOptions()Initializes the possible GardenPlants. -
searchPlant
Searches for a GardenPlant based on a plant name passed in- Parameters:
plantName
- name of plant- Returns:
- one of the GardenPlant options
-
searchRow
Finds the GardenRow based on an numerical input- Parameters:
row
- int that numerically represents the row
-
main
-