-
Notifications
You must be signed in to change notification settings - Fork 0
/
SavingAccount.java
61 lines (41 loc) · 1.29 KB
/
SavingAccount.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
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
52
53
54
55
56
57
58
59
60
61
package com.hyderabadbankapplication;
public class SavingAccount implements Account{
final static long account_Number=35402542052L;
private double totalBalance=2500;
public double getTotalBalance() {
return totalBalance;
}
public void setTotalBalance(double totalBalance) {
this.totalBalance = totalBalance;
}
@Override
public void withdraw(double amount) {
String action="DEBITED";
if(amount<=totalBalance) {
totalBalance-=amount;
displayMessage(action, amount);
}
else {
throw new IllegalArgumentException("Insuffiecient Fund");
}
}
@Override
public void deposit(double amount) {
String action="CREDITED";
if(amount<=100000) {
totalBalance+=amount;
displayMessage(action, amount);
}
else {
throw new IllegalArgumentException("Your are exceeding the Limits");
}
}
@Override
public void balanceInquiry() {
System.out.println("TotalBalance is:"+totalBalance);
}
@Override
public void displayMessage(String action, double amount) {
System.out.println("The account number "+account_Number+" and the amount is "+action+" the amount is "+amount+ " Total Balance is "+totalBalance+" from Hyderabad Bank....at 12Am 02/12/2023 visit again@@@@ thank you!...." );
}
}