Page 146 - AP Computer Science A, 7th edition
P. 146
Here is the framework for a simple bank account class:
public class BankAccount {
private String password;
private double balance;
public static final double OVERDRAWN_PENALTY = 20.00;
//constructors
/∗ ∗ Default constructor.
∗ Constructs bank account with default values. ∗/
public BankAccount()
{ /∗ implementation code ∗ / }
/∗ ∗ Constructs bank account with specified password and balance. ∗/
public BankAccount(String acctPassword, double acctBalance)
{ /∗ implementation code ∗ /
//accessor
/∗ ∗ @return balance of this public double getBalance() { /∗ implementation code ∗ /
//mutators
/∗∗ Deposits amount in bank password.
}
account }
∗ /
∗ @param acctPassword the password of this bank account
∗ @param amount the amount to be deposited
∗/
public void deposit(String acctPassword, double amount)
{ /∗ implementation code ∗ / }
/∗∗ Withdraws amount from bank account with given password.
∗ Assesses penalty if balance is less than amount.
∗ @param acctPassword the password of this
account with given