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

public class WateringCanLevelComponent extends Component
  • Field Summary

    Fields inherited from class com.csse3200.game.components.Component

    enabled, entity
  • Constructor Summary

    Constructors
    Constructor
    Description
    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(float newCapacity)
    Constructor with parameter to change the max level capacity The current ammount will still begin at 0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Remove all water from the watering can
    void
    Fill the current level of water to the max that can be stored
    float
    Get the private variable that represent the Max amount of water the WateringCan can hold and return it
    float
    Return the current amount of water within the WateringCan
    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
    boolean
    check and return whether the wateringCan is empty
    boolean
    Check and return whether the wateringCan is full
    void
    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 capacity
    void
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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)
      Specified by:
      write in interface com.badlogic.gdx.utils.Json.Serializable
      Overrides:
      write in class Component
    • read

      public void read(com.badlogic.gdx.utils.Json json, com.badlogic.gdx.utils.JsonValue jsonMap)
      Specified by:
      read in interface com.badlogic.gdx.utils.Json.Serializable
      Overrides:
      read in class Component