-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSavingAccount.java
More file actions
51 lines (46 loc) · 1.23 KB
/
Copy pathSavingAccount.java
File metadata and controls
51 lines (46 loc) · 1.23 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//1601890
//Ramy Fekry
public class SavingAccount extends Account {
private int numberWithdraw = 0;
private static double minBalance = 300;
private static int maxWithdraw = 3;
public SavingAccount(int id, double balance) {
super(id,balance);
}
public static double getMinBalance() {
return minBalance;
}
public static double getMaxWithdraw() {
return maxWithdraw;
}
public int getNumberWithdraw() {
return numberWithdraw;
}
public void setNumberWithdraw(int numWithdraw) {
this.numberWithdraw = numWithdraw;
}
@Override
public double getMonthlyInterestRate() {
return getAnnualInterestRate()/12;
}
@Override
public void withdraw(double amount) {
if (numberWithdraw < maxWithdraw)
{
if ((getBalance() - amount) >= minBalance) {
setBalance(getBalance() - amount);
numberWithdraw++;
}else {
System.out.println("You have insufficient balance");
}
}else {
System.out.println("You have reached your witdrawal limit");
}
}
@Override
public String toString(){
System.out.println("Account Number Balance");
String TheOutput = String.format("%14d%21.1f", getId(), getBalance()) + ("\n--------------------------------------------------");
return TheOutput;
}
}