-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSavingsAccount.java
More file actions
26 lines (22 loc) · 848 Bytes
/
SavingsAccount.java
File metadata and controls
26 lines (22 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
public class SavingsAccount extends BankAccount {
private static final double rate = 0.025;
private int savingsNumber = 0;
private String accountNumber;
public SavingsAccount(Person owner, double initialBalance) {
super(owner, initialBalance);
this.accountNumber = super.getAccountNumber() + "-" + savingsNumber;
}
public void postInterest() {
double monthlyInterest = (getBalance() * rate) / 12;
deposit(monthlyInterest);
}
@Override
public String getAccountNumber() {
return accountNumber;
}
public SavingsAccount(SavingsAccount original, double initialBalance) {
super(original.getOwner(), initialBalance);
this.savingsNumber = original.savingsNumber + 1;
this.accountNumber = super.getAccountNumber() + "-" + savingsNumber;
}
}