public class ParkingMeter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DIME_VALUE
Value of dime coin in cents.
|
static int |
NICKEL_VALUE
Value of nickel coin in cents.
|
static int |
QUARTER_VALUE
Value of quarter coin in cents.
|
Constructor and Description |
---|
ParkingMeter(int givenMinutesForNickel,
int givenMinutesForDime,
int givenMinutesForQuarter,
int givenMaxTime,
int givenMaxCoins)
Constructors ParkingTime by default is initially expired and contains no
coins
|
Modifier and Type | Method and Description |
---|---|
void |
emptyCoins()
emptyCoins reduces the coin to zero, without modifying the time
|
int |
getCents()
getCents returns the total amount of money, in cents, contained in this
meter
|
java.lang.String |
getDollarString()
getDollarString returns a String representing the total amount of money,
in dollars
|
java.lang.String |
getHourMinuteString()
getHourMinuteString() returns a String representing the time remaining on
the meter in the form "hh:mm"'
|
int |
getMinutesRemaining()
getMinutesRemaining returns the amount of time, in minutes, remaining on
this meter
|
int |
getTotalCoins()
getTotalCoins() returns the number of coins currently in this meter
|
void |
insertDimes(int howMany)
insertDimes(int howMany) inserts a given number of dimes into this meter,
increasing the coinRemainingNumerbers, coinRemainingValues, timeRemaining
until their limits
|
void |
insertNickels(int howMany)
insertNickels(int howMany) inserts a given number of dimes into this
meter, increasing the coinRemainingNumerbers, coinRemainingValues,
timeRemaining until their limits
|
void |
insertQuarters(int howMany)
insertQuarters(int howMany) inserts a given number of dimes into this
meter, increasing the coinRemainingNumerbers, coinRemainingValues,
timeRemaining until their limits
|
boolean |
isExpired()
isExpired() returns true if there is no time remaining, false otherwise.
|
void |
simulateTime(int minutes)
simulateTimeSimulates the passage of time for the given number of
minutes.
|
java.lang.String |
toString()
toString returns a String representation of this object in exactly the
following format.
|
public static final int NICKEL_VALUE
public static final int DIME_VALUE
public static final int QUARTER_VALUE
public ParkingMeter(int givenMinutesForNickel, int givenMinutesForDime, int givenMinutesForQuarter, int givenMaxTime, int givenMaxCoins)
givenMinutesForNickel
- Added time for one nickel inserted, by default in minutes,
error alerted if negativegivenMinutesForDime
- Added time for one dime inserted, by default in minutes, error
alerted if negativegivenMinutesForQuarter
- Added time for one quarter inserted, by default in minutes,
error alerted if negativegivenMaxTime
- The max time by default in minutes, error alerted if negativegivenMaxCoins
- The max number of coin that can be inserted, error alerted if
negativepublic void simulateTime(int minutes)
minutes
- The passage of time, in minutes by defaultpublic void emptyCoins()
public int getCents()
public java.lang.String getDollarString()
public int getMinutesRemaining()
public java.lang.String getHourMinuteString()
public int getTotalCoins()
public void insertDimes(int howMany)
howMany
- The number of coins insertedpublic void insertNickels(int howMany)
howMany
- The number of coins insertedpublic void insertQuarters(int howMany)
howMany
- The number of coins insertedpublic boolean isExpired()
public java.lang.String toString()
toString
in class java.lang.Object