class BankAccount extends Object
| Modifier and Type | Field and Description |
|---|---|
private static double |
annualInterestRate |
private double |
balance |
private Date |
dateCreated |
private int |
id |
| Constructor and Description |
|---|
BankAccount()
default constructor: id is initialized 0
balance is initialized 1000.0
|
BankAccount(int newId,
double newBalance)
constructor that creates an account with the specified id and initial balance
|
| Modifier and Type | Method and Description |
|---|---|
void |
deposit(double amount)
Precondition: amount must be positive
Postcondition: balance is updated (balance + amount)
|
static double |
getAnnualInterestRate()
accessor method for the static variable annualInterestRate
|
double |
getBalance()
accessor method for balance
|
Date |
getDateCreated()
accessor method for dateCreated
|
int |
getId()
accessor method for id
|
double |
getMonthlyInterest()
calculate monthly interest: balance * annualInterestRate / 1200.0
|
static void |
setAnnualInterestRate(double newAnnualInterestRate)
mutator method for annualInterestRate
|
void |
setBalance(double newBalance)
mutator method for balance
|
void |
setId(int newId)
mutator method for id
|
void |
withdraw(double amount)
Precondition: amount must be positive and less than the balance
Postcondition: balance is updated (balance - amount)
|
private int id
private double balance
private static double annualInterestRate
private Date dateCreated
public BankAccount()
public BankAccount(int newId,
double newBalance)
newId - newBalance - public int getId()
public double getBalance()
public static double getAnnualInterestRate()
public void setId(int newId)
newId - public void setBalance(double newBalance)
newBalance - public static void setAnnualInterestRate(double newAnnualInterestRate)
newAnnualInterestRate - public double getMonthlyInterest()
public Date getDateCreated()
public void withdraw(double amount)
amount - public void deposit(double amount)
amount -