Package core.components
Class User
- java.lang.Object
-
- core.components.User
-
- Direct Known Subclasses:
Manager
public class User extends java.lang.Object
The User class : This class defines what a user is, what a user has and how he will behave in the application
-
-
Constructor Summary
Constructors Constructor Description User(java.lang.String name, java.awt.Point coordinate, long creditCardNumber, double money)
The User contructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCard(java.lang.String cardType)
Add a new card for the uservoid
addMoney(double money)
Add money balancevoid
addRenting()
Increment number of rentings by one It used to compute statisticsvoid
addSpentTimeOnElectricalBicycle(double intervalOfTime)
Update the time spent on electrical bicyclesvoid
addSpentTimeOnMechanicalBicycle(double intervalOfTime)
Update the time spent on mechanical bicyclesvoid
addTimeCredit(double time)
Add some time credit after the user had dropped the bicycle in a good stationjava.lang.String
displaySystemReport(MyVelibSystem system)
Used to display the system the user is usingvoid
dropBicyclePlanning(MyVelibSystem system, java.awt.Point coordsStart, java.awt.Point coordsEnd)
Dropping a bicycle after using itvoid
dropBicyclePlanningWithIntervalOfTime(MyVelibSystem system, java.awt.Point coordsStart, java.awt.Point coordsEnd, double intervalOfTime)
Droping a bicycle after using itboolean
equals(java.lang.Object o)
equals method for the userfloat
getAllMoneyCharged()
Bicycle
getBicycle()
Card
getCard()
java.awt.Point
getCoordinate()
long
getCreditCardNumber()
float
getCurrentMoneyCharged()
int
getId()
double
getMoney()
java.lang.String
getName()
int
getNumberOfRentings()
static int
getNumberOfUsers()
int
getRentStationID()
java.time.LocalTime
getRentTime()
float
getTimeCreditBalance()
double
getTimeSpentOnElectricalBicycle()
double
getTimeSpentOnMechanicalBicycle()
int
hashCode()
hashCode method for uservoid
removeMoney(double money)
Remove money balance after droping the bicyclevoid
removeTimeCredit(double time)
Remove time balance after the computation of the location costvoid
rentBicyclePlanning(MyVelibSystem system, java.awt.Point coordsStart, java.awt.Point coordsEnd, Bicycle bicycle)
Renting a bicyclejava.lang.String
seeCurrentStationState(MyVelibSystem system, int stationID)
Used to see the state of an existing stationjava.lang.String
seeCurrentStatus(MyVelibSystem system, int userID)
java.lang.String
seeMyStatus()
Used to see the status of the uservoid
setAllMoneyCharged(float allMoneyCharged)
Update the value of all money the user has been chargedvoid
setBicycle(Bicycle bicycle)
Update the bicycle of the uservoid
setCard(Card card)
Update the card of the uservoid
setCoordinate(java.awt.Point coordinate)
Update the coordinate of the uservoid
setCreditCardNumber(long creditCardNumber)
Update the credit card number of the uservoid
setCurrentMoneyCharged(float currentMoneyCharged)
Update the current money the user is chargedvoid
setMoney(double money)
Update the money balance of the uservoid
setName(java.lang.String name)
Update the name of the uservoid
setNumberOfRentings(int numberOfRentings)
Update the number of rentings of the uservoid
setRentStationID(int rentStationID)
Update the last renting station ID of the uservoid
setRentTime(java.time.LocalTime rentTime)
Update the actual renting time of the uservoid
setTimeCreditBalance(float timeCreditBalance)
Update the time credit balance of the uservoid
setTimeSpentOnElectricalBicycle(double timeSpentOnElectricalBicycle)
Update the time spent by the user on electrical bicyclevoid
setTimeSpentOnMechanicalBicycle(double timeSpentOnMechanicalBicycle)
Update the time spent by the user on mechanical bicyclejava.lang.String
toString()
toString method for user
-
-
-
Constructor Detail
-
User
public User(java.lang.String name, java.awt.Point coordinate, long creditCardNumber, double money)
The User contructor- Parameters:
name
- : name of the usercoordinate
- : coordinate of the usercreditCardNumber
- : credit card number of the usermoney
- : inital money balance of the user
-
-
Method Detail
-
getId
public int getId()
- Returns:
- the id of the user
-
getNumberOfUsers
public static int getNumberOfUsers()
- Returns:
- the number of Users in the system
-
getName
public java.lang.String getName()
- Returns:
- the name of the User
-
getCoordinate
public java.awt.Point getCoordinate()
- Returns:
- the coordinate of the user
-
getCard
public Card getCard()
- Returns:
- the Card of the User (Vlibre/Vmax/none)
-
getCreditCardNumber
public long getCreditCardNumber()
- Returns:
- the credit card number of the user
-
getTimeCreditBalance
public float getTimeCreditBalance()
- Returns:
- the time credit balance of the user
-
getAllMoneyCharged
public float getAllMoneyCharged()
- Returns:
- All the money the user has been charged
-
getCurrentMoneyCharged
public float getCurrentMoneyCharged()
- Returns:
- the current money charged for the user
-
getBicycle
public Bicycle getBicycle()
- Returns:
- the bicycle the user is using if he is in a location
-
getRentStationID
public int getRentStationID()
- Returns:
- the station ID where the user rented the bicycle he is using right now. None if he does not.
-
getRentTime
public java.time.LocalTime getRentTime()
- Returns:
- the time when he rented his last bicycle
-
getMoney
public double getMoney()
- Returns:
- the money balace of the user
-
getNumberOfRentings
public int getNumberOfRentings()
- Returns:
- the user's number of rentings
-
getTimeSpentOnElectricalBicycle
public double getTimeSpentOnElectricalBicycle()
- Returns:
- the time the user spent on a electical bicycle
-
getTimeSpentOnMechanicalBicycle
public double getTimeSpentOnMechanicalBicycle()
- Returns:
- the time the user spent on a mechanical bicycle
-
setName
public void setName(java.lang.String name)
Update the name of the user- Parameters:
name
- name for the user
-
setCoordinate
public void setCoordinate(java.awt.Point coordinate)
Update the coordinate of the user- Parameters:
coordinate
- coordinate that the user will be created
-
setCard
public void setCard(Card card)
Update the card of the user- Parameters:
card
- a card that will be used to set the user's card
-
setCreditCardNumber
public void setCreditCardNumber(long creditCardNumber)
Update the credit card number of the user- Parameters:
creditCardNumber
- a credit card number
-
setTimeCreditBalance
public void setTimeCreditBalance(float timeCreditBalance)
Update the time credit balance of the user- Parameters:
timeCreditBalance
- a double that represents the time credit balance (in minutes)
-
setAllMoneyCharged
public void setAllMoneyCharged(float allMoneyCharged)
Update the value of all money the user has been charged- Parameters:
allMoneyCharged
- the value of all money the user has been charged
-
setCurrentMoneyCharged
public void setCurrentMoneyCharged(float currentMoneyCharged)
Update the current money the user is charged- Parameters:
currentMoneyCharged
- the current money the user is charged
-
setBicycle
public void setBicycle(Bicycle bicycle)
Update the bicycle of the user- Parameters:
bicycle
- the bicycle of the user (can be none)
-
setRentStationID
public void setRentStationID(int rentStationID)
Update the last renting station ID of the user- Parameters:
rentStationID
- the last renting station ID of the user
-
setRentTime
public void setRentTime(java.time.LocalTime rentTime)
Update the actual renting time of the user- Parameters:
rentTime
- the actual renting time of the user
-
setMoney
public void setMoney(double money)
Update the money balance of the user- Parameters:
money
- the money balance of the user
-
setNumberOfRentings
public void setNumberOfRentings(int numberOfRentings)
Update the number of rentings of the user- Parameters:
numberOfRentings
- the number of rentings of the user
-
setTimeSpentOnElectricalBicycle
public void setTimeSpentOnElectricalBicycle(double timeSpentOnElectricalBicycle)
Update the time spent by the user on electrical bicycle- Parameters:
timeSpentOnElectricalBicycle
- the time spent by the user on electrical bicycle
-
setTimeSpentOnMechanicalBicycle
public void setTimeSpentOnMechanicalBicycle(double timeSpentOnMechanicalBicycle)
Update the time spent by the user on mechanical bicycle- Parameters:
timeSpentOnMechanicalBicycle
- the time spent by the user on mechanical bicycle
-
toString
public java.lang.String toString()
toString method for user- Overrides:
toString
in classjava.lang.Object
- Returns:
- a message that represent the user object
-
equals
public boolean equals(java.lang.Object o)
equals method for the user- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- an object- Returns:
- true, if the two objects are "equal". false, otherwise
-
hashCode
public int hashCode()
hashCode method for user- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- hash(id, name, coordinate, card, creditCardNumber, timeCreditBalance, allMoneyCharged, currentMoneyCharged)
-
addCard
public void addCard(java.lang.String cardType)
Add a new card for the user- Parameters:
cardType
- a string for the card type (Can be Vmax, Vlibre or None)
-
addMoney
public void addMoney(double money)
Add money balance- Parameters:
money
- the money that will be added
-
removeMoney
public void removeMoney(double money)
Remove money balance after droping the bicycle- Parameters:
money
- the money that will be removed
-
addTimeCredit
public void addTimeCredit(double time)
Add some time credit after the user had dropped the bicycle in a good station- Parameters:
time
- some time credit (in minutes)
-
removeTimeCredit
public void removeTimeCredit(double time)
Remove time balance after the computation of the location cost- Parameters:
time
- time balance after the computation of the location cost
-
rentBicyclePlanning
public void rentBicyclePlanning(MyVelibSystem system, java.awt.Point coordsStart, java.awt.Point coordsEnd, Bicycle bicycle)
Renting a bicycle- Parameters:
system
- : the system the user is usingcoordsStart
- : the coordinate where the user want to startcoordsEnd
- : the coordinate wher the user want to finish his locationbicycle
- : the bicycle the user wants to rent
-
dropBicyclePlanning
public void dropBicyclePlanning(MyVelibSystem system, java.awt.Point coordsStart, java.awt.Point coordsEnd)
Dropping a bicycle after using it- Parameters:
system
- : the system the user is usingcoordsStart
- : the coordinate where the user want to startcoordsEnd
- : the coordinate wher the user want to finish his location
-
dropBicyclePlanningWithIntervalOfTime
public void dropBicyclePlanningWithIntervalOfTime(MyVelibSystem system, java.awt.Point coordsStart, java.awt.Point coordsEnd, double intervalOfTime)
Droping a bicycle after using it- Parameters:
system
- : the system the user is usingcoordsStart
- : the coordinate where the user want to startcoordsEnd
- : the coordinate wher the user want to finish his locationintervalOfTime
- : the interval of time the user used the bicycle between the renting and the droping
-
addRenting
public void addRenting()
Increment number of rentings by one It used to compute statistics
-
addSpentTimeOnElectricalBicycle
public void addSpentTimeOnElectricalBicycle(double intervalOfTime)
Update the time spent on electrical bicycles- Parameters:
intervalOfTime
- an interval of time (in minutes)
-
addSpentTimeOnMechanicalBicycle
public void addSpentTimeOnMechanicalBicycle(double intervalOfTime)
Update the time spent on mechanical bicycles- Parameters:
intervalOfTime
- an interval of time (in minutes)
-
seeMyStatus
public java.lang.String seeMyStatus()
Used to see the status of the user- Returns:
- user's toString
-
seeCurrentStatus
public java.lang.String seeCurrentStatus(MyVelibSystem system, int userID)
- Parameters:
system
- : the system the user is usinguserID
- : the ID the user wants to see- Returns:
- A string to see the current status
-
seeCurrentStationState
public java.lang.String seeCurrentStationState(MyVelibSystem system, int stationID)
Used to see the state of an existing station- Parameters:
system
- : the system the user is usingstationID
- : the station id the user wants to see- Returns:
- A string to see the current status
-
displaySystemReport
public java.lang.String displaySystemReport(MyVelibSystem system)
Used to display the system the user is using- Parameters:
system
- : the system the user is using- Returns:
- A string to see the current status
-
-