public class SmartANZAsia10Card extends PhoneCard
Each card also keeps track of the history of the charges made to the card. As an example, a brand new card would have a empty charge history of { }. If the card was used to call Australia for 10 minutes, its charge history would be { 2.50 }, and its balance would be $7.50. If the card was then used to call Asia for 20 minutes, its charge history would be { 2.50, 4.00 }, and its balance would be $3.50. Finally, after deducting the first week of fees, its charge history would be { 2.50, 4.00, 0.50 }, and its balance would be $3.00.
Modifier and Type | Field and Description |
---|---|
static double |
COST_PER_MIN_TO_ANZ
The cost per minute for calls to Australia and New Zealand for
SmartANZAsia10 cards.
|
static double |
COST_PER_MIN_TO_ASIA
The cost per minute for calls to Asia for SmartANZAsia10 cards.
|
static double |
INITIAL_BALANCE
The initial balance for SmartANZAsia10 cards.
|
static double |
WEEKLY_FEES
The weekly fee for SmartANZAsia10 cards.
|
Constructor and Description |
---|
SmartANZAsia10Card(long number,
int password)
Create a SmartANZAsia10Card phone card with the given number and
password.
|
SmartANZAsia10Card(SmartANZAsia10Card card)
Create a copy of the given SmartANZAsia10Card.
|
Modifier and Type | Method and Description |
---|---|
Set<CallZone> |
allowedZones()
Get the set of call zones that can be called on this phone card.
|
boolean |
charge(int minutes,
CallZone zone)
Charge a call of the given number of minutes to the zone.
|
double |
costPerMin(CallZone zone)
Get the cost per minute of a call to the argument zone on this phone
card.
|
void |
deductWeeklyFee()
Deduct the appropriate weekly fees from the card's balance.
|
boolean |
equals(Object obj)
Compares the card with another object for equality.
|
List<Double> |
getChargeHistory()
Get the history of charges as a List.
|
boolean |
isAllowed(CallZone zone)
Check whether a call to the argument zone is allowed for this phone card.
|
getBalance, getLimit, getNumber, getPassword, setBalance, toString
public static final double INITIAL_BALANCE
public static final double WEEKLY_FEES
public static final double COST_PER_MIN_TO_ANZ
public static final double COST_PER_MIN_TO_ASIA
public SmartANZAsia10Card(long number, int password)
number
- The phone card's number.password
- The phone card's password.public SmartANZAsia10Card(SmartANZAsia10Card card)
card
- the card to make a copy of.public List<Double> getChargeHistory()
public Set<CallZone> allowedZones()
allowedZones
in class PhoneCard
public double costPerMin(CallZone zone)
costPerMin
in class PhoneCard
zone
- The call zone to find the cost for.public void deductWeeklyFee()
deductWeeklyFee
in class PhoneCard
public boolean isAllowed(CallZone zone)
public boolean charge(int minutes, CallZone zone)
public boolean equals(Object obj)