Class Station

  • Direct Known Subclasses:
    PlusStation, StandardStation

    public abstract class Station
    extends java.lang.Object
    The Station class : This class defines what stations are and how they behave
    • Constructor Detail

      • Station

        public Station​(java.awt.Point coordinate,
                       boolean onService,
                       java.util.List<ParkingSlot> parkingSlots,
                       double money,
                       int numberOfDroppings)
        A Station constructor
        Parameters:
        coordinate - coordinate that will be used to place a plus station
        onService - a boolean parameter to know if the station will be on service
        parkingSlots - a list of parking slots that will populate the plus station
        money - the initial money that the station will have
        numberOfDroppings - the number of droppings (or locations)
      • Station

        public Station​(java.awt.Point coordinate,
                       boolean onService,
                       java.util.List<ParkingSlot> parkingSlots)
        A (simpler) Station constructor
        Parameters:
        coordinate - coordinate that will be used to place a plus station
        onService - a boolean parameter to know if the station will be on service
        parkingSlots - a list of parking slots that will populate the plus station
    • Method Detail

      • getId

        public int getId()
        getter for id
        Returns:
        the id
      • isOnService

        public boolean isOnService()
        getter for onService parameter
        Returns:
        onService parameter
      • setOnService

        public void setOnService​(boolean onService)
        setter for onService parameter
        Parameters:
        onService - a boolean that will be used to set onService parameter
      • getCoordinate

        public java.awt.Point getCoordinate()
        getter for coordinate
        Returns:
        coordinate
      • setCoordinate

        public void setCoordinate​(java.awt.Point coordinate)
        setter for coordinate (maybe the relevance of this method could be discussed)
        Parameters:
        coordinate - coordinate that will be used to set the station coordinate
      • getParkingSlots

        public java.util.List<ParkingSlot> getParkingSlots()
        getter for the list of parking slots
        Returns:
        parkingSlots (a list of parking slots)
      • setParkingSlots

        public void setParkingSlots​(java.util.List<ParkingSlot> parkingSlots)
        setter for parkingSlots
        Parameters:
        parkingSlots - a list of parking slots
      • getStationTerminal

        public Terminal getStationTerminal()
        getter for the terminal of the station
        Returns:
        the terminal object
      • getNumberOfStations

        public static int getNumberOfStations()
        getter for the number of stations
        Returns:
        number of stations in the application
      • getMoney

        public double getMoney()
        getter for the money parameter
        Returns:
        the total amount of money that stations has (it can be used to see the station profit)
      • setMoney

        public void setMoney​(double money)
        setter for the money parameter
        Parameters:
        money - the total amount of money that the station has
      • getNumberOfDroppings

        public int getNumberOfDroppings()
        getter for the number of droppings (or complete locations)
        Returns:
        the number of droppings
      • setNumberOfDroppings

        public void setNumberOfDroppings​(int numberOfDroppings)
        setter for the number of droppings
        Parameters:
        numberOfDroppings - the number of complete locations (or droppings)
      • getNumberOfRentings

        public int getNumberOfRentings()
        getter for the number of rentings
        Returns:
        the number of rentings
      • setNumberOfRentings

        public void setNumberOfRentings​(int numberOfRentings)
        setter for the number of rentings
        Parameters:
        numberOfRentings - the number of rentings to be used in the setting process
      • toString

        public java.lang.String toString()
        toString method for Station
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string that represents the station
      • equals

        public boolean equals​(java.lang.Object o)
        equals method for Station
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - an object
        Returns:
        true or false
      • hashCode

        public int hashCode()
        hashCode method for Station
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hash(id, coordinate, onService, parkingSlots, terminal, money, numberOfDroppings, numberOfRentings)
      • getExistTypeBike

        public boolean getExistTypeBike​(Bicycle bicycle)
        This method will return a boolean that represents the existence or not of give bicycle type
        Parameters:
        bicycle - a bicycle object, either electrical or mechanical bicycle
        Returns:
        true, if the station has a bicycle of the same type. false, otherwise
      • hasAvailableElectricalBicycle

        public boolean hasAvailableElectricalBicycle()
        This method is used to see if a station has an available electrical bicycle to be rented
        Returns:
        true, if the station has an available electrical bicycle. false, otherwise
      • hasAvailableMechanicalBicycle

        public boolean hasAvailableMechanicalBicycle()
        This method is used to see if a station has an available mechanical bicycle to be rented
        Returns:
        true, if the station has an available mechanical bicycle. false, otherwise
      • hasOneSlotFree

        public boolean hasOneSlotFree()
        This method checks if a station has a free slot
        Returns:
        true, if the station has a free slot. false, otherwise
      • getOneFreeSlot

        public ParkingSlot getOneFreeSlot()
        This method is a getter for a free slot. If it has not a free slot, it returns null
        Returns:
        a free slot if the station has any. null, otherwise
      • getParkingSlotTypeBicycle

        public ParkingSlot getParkingSlotTypeBicycle​(Bicycle bicycle)
        This method gets a parking slot for the type of bicycle that is passed as argument
        Parameters:
        bicycle - any bicycle in the application (can be electrical or mechanical)
        Returns:
        a slot of the give bicycle if there is any. null, otherwise
      • getElectricalParkingSlot

        public ParkingSlot getElectricalParkingSlot()
        This method get an electrical parking slot (that is a parking slot that has an electrical bicycle) if there is any
        Returns:
        an electrical parking slot if there is any in the station. null, otherwise
      • getMechanicalParkingSlot

        public ParkingSlot getMechanicalParkingSlot()
        This method get a mechanical parking slot (that is a parking slot that has an mechanical bicycle) if there is any
        Returns:
        a mechanical parking slot if there is any in the station. null, otherwise
      • addMoney

        public void addMoney​(double money)
        This methods adds money in the station
        Parameters:
        money - The amount of money to be added to the station
      • removeMoney

        public void removeMoney​(double money)
        This methods removes money in the station
        Parameters:
        money - The amount of money to be removed from the station
      • addNumberOfDroppings

        public void addNumberOfDroppings​(int number)
        This methods adds the number of droppings
        Parameters:
        number - The number that will be used to increase the number of droppings
      • addNumberOfRentings

        public void addNumberOfRentings​(int number)
        This methods adds the number of rentings
        Parameters:
        number - The number that will be used to increase the number of rentings