-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSavingsAccount.java
More file actions
31 lines (22 loc) · 855 Bytes
/
SavingsAccount.java
File metadata and controls
31 lines (22 loc) · 855 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
27
28
29
30
31
public class SavingsAccount extends Account {
private double minimumBalance = 100.00;
public SavingsAccount(int accountId, double startBalance) {
super(accountId, startBalance);
}
@Override
public double withdraw(double amount) {
if (getBalance() - amount < minimumBalance) {
System.out.println("Cannot go below minimum balance of $100!");
return 0;
}
return super.withdraw(amount);
}
@Override
public String toString() {
return "\n--- Savings Account ---" +
"\nAccount ID: " + getId() +
"\nBalance: $" + String.format("%.2f", getBalance()) +
"\nMinimum Balance: $" + String.format("%.2f", minimumBalance) +
"\nDate Created: " + getDateCreated();
}
}