## Class SmartANZAsia10Card

• ```public class SmartANZAsia10Card
extends PhoneCard```
A class that represents a smart phone card for Australia, New Zealand, and Asia. For SmartANZAsia10 phone cards, only calls to Australia, New Zealand, and Asia. are allowed. For calls to Australia and New Zealand the cost per minute is \$0.25, and for calls to Asia the cost per minute is \$0.20. The initial balance on the card is \$10.00. The weekly fees are \$0.50.

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.

Author:
CSE1030
• ### Field Summary

Fields
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 Summary

Constructors
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.
• ### Method Summary

Methods
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.
• ### Methods inherited from class PhoneCard

`getBalance, getLimit, getNumber, getPassword, setBalance, toString`
• ### Methods inherited from class java.lang.Object

`getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### INITIAL_BALANCE

`public static final double INITIAL_BALANCE`
The initial balance for SmartANZAsia10 cards.
Constant Field Values
• #### WEEKLY_FEES

`public static final double WEEKLY_FEES`
The weekly fee for SmartANZAsia10 cards.
Constant Field Values
• #### COST_PER_MIN_TO_ANZ

`public static final double COST_PER_MIN_TO_ANZ`
The cost per minute for calls to Australia and New Zealand for SmartANZAsia10 cards.
Constant Field Values
• #### COST_PER_MIN_TO_ASIA

`public static final double COST_PER_MIN_TO_ASIA`
The cost per minute for calls to Asia for SmartANZAsia10 cards.
Constant Field Values
• ### Constructor Detail

• #### SmartANZAsia10Card

```public SmartANZAsia10Card(long number,
Create a SmartANZAsia10Card phone card with the given number and password. Sets the charge history of the card to empty.
Parameters:
`number` - The phone card's number.
`password` - The phone card's password.
Precondition:
• #### SmartANZAsia10Card

`public SmartANZAsia10Card(SmartANZAsia10Card card)`
Create a copy of the given SmartANZAsia10Card. A deep copy is returned.
Parameters:
`card` - the card to make a copy of.
• ### Method Detail

• #### getChargeHistory

`public List<Double> getChargeHistory()`
Get the history of charges as a List. The client can modify the returned List without changing the state of the card.
Returns:
A List containing the charge history of the card.
• #### allowedZones

`public Set<CallZone> allowedZones()`
Get the set of call zones that can be called on this phone card. For SmartANZAsia10 phone cards, only calls to Australia, New Zealand, and Asia are allowed.
Specified by:
`allowedZones` in class `PhoneCard`
Returns:
the set of call zones.
• #### costPerMin

`public double costPerMin(CallZone zone)`
Get the cost per minute of a call to the argument zone on this phone card.
Specified by:
`costPerMin` in class `PhoneCard`
Parameters:
`zone` - The call zone to find the cost for.
Precondition:
a call to zone is allowed for this card.
Returns:
The cost per minute to call the given call zone.
• #### deductWeeklyFee

`public void deductWeeklyFee()`
Deduct the appropriate weekly fees from the card's balance. If the balance is insufficient, the balance becomes 0. Updates the charge history with the amount deducted from the card's balance.
Specified by:
`deductWeeklyFee` in class `PhoneCard`
• #### isAllowed

`public boolean isAllowed(CallZone zone)`
Check whether a call to the argument zone is allowed for this phone card. For SmartANZAsia10 phone cards, only calls to Australia, New Zealand, and Asia are allowed.
Specified by:
`isAllowed` in class `PhoneCard`
Parameters:
`zone` - the call zone to check.
Returns:
true if the card supports the call zone; false otherwise.
• #### charge

```public boolean charge(int minutes,
CallZone zone)```
Charge a call of the given number of minutes to the zone. This method tries to charge a call to zone with the given number of minutes to the card; if the balance is sufficient to cover it, it returns true and if the balance is not sufficient, it leaves it unchanged and returns false. When a call is charged to the balance, the charge is recorded in the charge history of the card.
Overrides:
`charge` in class `PhoneCard`
Parameters:
`minutes` - the number of minutes to charge.
`zone` - the zone that the call is going to.
Precondition:
minutes is positive and a call to zone is allowed for this card.
Returns:
true if the balance was sufficient to pay for the call, and false otherwise.
• #### equals

`public boolean equals(Object obj)`
Compares the card with another object for equality. Two cards are equal if and only if their PhoneCard sub-objects are equal and their charge histories are equal.
Overrides:
`equals` in class `PhoneCard`
Parameters:
`obj` - the object to compare with for equality.
Returns:
true if the card and object are equal; false otherwise.