-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCurrentAccount.java
26 lines (23 loc) · 1016 Bytes
/
CurrentAccount.java
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 CurrentAccount extends Account {
public double overdraftLimit;
public CurrentAccount(int accountNumber, String accountHolder, double balance, int overdraftLimit) {
super(accountNumber, accountHolder, balance);
this.overdraftLimit = overdraftLimit;
}
@Override
public void withdraw(double amount) {
if ((overdraftLimit + balance) >= amount) {
if (amount <= balance) {
balance -= amount;
System.out.println("Withdrawal of " + amount + "Tk successful. New balance: " + balance);
} else {
balance = 0;
overdraftLimit -= amount - balance;
System.out.println("Withdrawal of " + amount + "TK successful. New balance: " + balance +
"Tk. Overdraft limit remaining: " + overdraftLimit + "Tk.");
}
} else {
System.out.println("You don't have sufficient balance.");
}
}
}