Class ParkingSlot


  • public class ParkingSlot
    extends java.lang.Object
    The ParkingSlot class: This class defines what is a parking slot and how it will behave in the application
    • Constructor Summary

      Constructors 
      Constructor Description
      ParkingSlot()
      The ParkingSlot constructor (that take no argument)
      ParkingSlot​(int state, Bicycle bicycle)
      The ParkingSlot constructor
    • Constructor Detail

      • ParkingSlot

        public ParkingSlot​(int state,
                           Bicycle bicycle)
        The ParkingSlot constructor
        Parameters:
        state - an initial state
        bicycle - an initial bicycle (may be null)
      • ParkingSlot

        public ParkingSlot()
        The ParkingSlot constructor (that take no argument)

        This constructor will set the initial state to zero (free)

    • Method Detail

      • setState

        public void setState​(int state)
        Setter for state
        Parameters:
        state - the state of the parking slot
      • setState

        public void setState​(int state,
                             Bicycle bicycle)
        Setter for state
        Parameters:
        state - the state of the parking slot
        bicycle - a bicycle parameter that the slot will storage
      • getBicycle

        public Bicycle getBicycle()
        Getter for bicycle
        Returns:
        bicycle
      • setBicycle

        public void setBicycle​(Bicycle bicycle)
        Setter for bicycle
        Parameters:
        bicycle - bicycle
      • getState

        public int getState()
        Getter for state
        Returns:
        state
      • getId

        public int getId()
        Getter for id
        Returns:
        id
      • getNumberOfSlots

        public static int getNumberOfSlots()
        Getter for numberOfSlots
        Returns:
        numberOfSlots
      • toString

        public java.lang.String toString()
        toString method for the ParkingSlot class
        Overrides:
        toString in class java.lang.Object
        Returns:
        a message that represent the ParkingSlot object
      • equals

        public boolean equals​(java.lang.Object o)
        equals method for the ParkingSlot class
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - an object
        Returns:
        true, if the two objects are "equal"; false, otherwise
      • hashCode

        public int hashCode()
        hashCode method for the ParkingSlot class
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hash(id, state)