Class WateringCanLevelComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.items.WateringCanLevelComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor that will set the watering can level values to default values - The max the watering can will be set to 50 - The current amount of water in the can will be 0WateringCanLevelComponent
(float newCapacity) Constructor with parameter to change the max level capacity The current ammount will still begin at 0 -
Method Summary
Modifier and TypeMethodDescriptionvoid
empty()
Remove all water from the watering canvoid
Fill the current level of water to the max that can be storedfloat
Get the private variable that represent the Max amount of water the WateringCan can hold and return itfloat
Return the current amount of water within the WateringCanvoid
incrementLevel
(float increment) increment the current amount of water by the given amount of water check to see if the can is not at capacityboolean
isEmpty()
check and return whether the wateringCan is emptyboolean
isFull()
Check and return whether the wateringCan is fullvoid
read
(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonMap) void
setCapacity
(float newCapacity) Update the max the WateringCan can hold to the parameter and keep the current level of water but adjust current level to max if the water in the can is greater than max capacityvoid
setCurrentLevel
(float newAmount) Set the value that stores the current amount of water to the parameter --- e.g.void
write
(com.badlogic.gdx.utils.Json json) Methods inherited from class com.csse3200.game.components.Component
create, dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
WateringCanLevelComponent
public WateringCanLevelComponent()Constructor that will set the watering can level values to default values - The max the watering can will be set to 50 - The current amount of water in the can will be 0 -
WateringCanLevelComponent
public WateringCanLevelComponent(float newCapacity) Constructor with parameter to change the max level capacity The current ammount will still begin at 0- Parameters:
newCapacity
- Max capacity the water can will hold as a float
-
-
Method Details
-
getCapacity
public float getCapacity()Get the private variable that represent the Max amount of water the WateringCan can hold and return it- Returns:
- capacity
-
setCapacity
public void setCapacity(float newCapacity) Update the max the WateringCan can hold to the parameter and keep the current level of water but adjust current level to max if the water in the can is greater than max capacity- Parameters:
newCapacity
-
-
getCurrentLevel
public float getCurrentLevel()Return the current amount of water within the WateringCan- Returns:
- currentLevel
-
setCurrentLevel
public void setCurrentLevel(float newAmount) Set the value that stores the current amount of water to the parameter --- e.g. Set to Max, or Reset back to 0- Parameters:
newAmount
-
-
incrementLevel
public void incrementLevel(float increment) increment the current amount of water by the given amount of water check to see if the can is not at capacity- Parameters:
increment
-
-
fillToMax
public void fillToMax()Fill the current level of water to the max that can be stored -
empty
public void empty()Remove all water from the watering can -
isFull
public boolean isFull()Check and return whether the wateringCan is full- Returns:
- true if full, false otherwise
-
isEmpty
public boolean isEmpty()check and return whether the wateringCan is empty- Returns:
- true if empty, false otherwise
-
write
public void write(com.badlogic.gdx.utils.Json json) -
read
public void read(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonMap)
-