-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurrent.java
More file actions
34 lines (27 loc) · 1003 Bytes
/
Copy pathCurrent.java
File metadata and controls
34 lines (27 loc) · 1003 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
32
33
34
public class Current extends Account{
private double initialBalance=0.0;
public Current(String accountId, String accountName, String password, double balance) {
super(accountId, accountName, password);
this.initialBalance = balance;
super.credit(initialBalance);
}
public double debit(double ammount){
if(ammount<=(getBalance()+initialBalance )){
return super.debit(ammount);
}
else{
return getBalance();}
}
public double transferFunds(double ammount, Account account) {
if(ammount>0 && getBalance()-ammount>=0){
super.debit(ammount);
account.credit(ammount);
}
else{
System.out.println("You don't have enough money");}
return getBalance();
}
public String toString() {
return "Account= \n id" + getAccountId() + " accountName=" + getAccountName() + ", balance=" + getBalance();
}
}