Class Carrot

  • All Implemented Interfaces:
    Plant

    public class Carrot
    extends java.lang.Object
    implements Plant
    • Constructor Summary

      Constructors 
      Constructor Description
      Carrot()
      Constructs a brand new carrot, with medium water to start.
      Carrot​(java.lang.String name)
      Constructs a brand new carrot and gives it a particular name, with medium water to start.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void elapseDay()
      Elapses a day in the life of the carrot.
      java.lang.String getName()
      All carrots are named Carrot by default, unless another name was set on construction.
      java.lang.String getStatus()
      Returns a String describing the current state of the carrot.
      int getWaterLevel()
      Gets the water level of the carrot.
      void waterPlant​(int unitsWater)
      Waters the carrot
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Carrot

        public Carrot()
        Constructs a brand new carrot, with medium water to start.
      • Carrot

        public Carrot​(java.lang.String name)
        Constructs a brand new carrot and gives it a particular name, with medium water to start.
        Parameters:
        name - the name of this new carrot.
    • Method Detail

      • getName

        public java.lang.String getName()
        All carrots are named Carrot by default, unless another name was set on construction.
        Specified by:
        getName in interface Plant
        Returns:
        the String representing the name
      • waterPlant

        public void waterPlant​(int unitsWater)
        Waters the carrot
        Specified by:
        waterPlant in interface Plant
        Parameters:
        unitsWater - number of units of water that the carrot was given
      • elapseDay

        public void elapseDay()
        Elapses a day in the life of the carrot. This makes the carrot older and decreases the current level of water.
        Specified by:
        elapseDay in interface Plant
      • getStatus

        public java.lang.String getStatus()
        Returns a String describing the current state of the carrot.
        Specified by:
        getStatus in interface Plant
        Returns:
        description of carrot
      • getWaterLevel

        public int getWaterLevel()
        Gets the water level of the carrot.
        Specified by:
        getWaterLevel in interface Plant
        Returns:
        water level