-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAtmOperationImpl.java
More file actions
41 lines (33 loc) · 1.33 KB
/
Copy pathAtmOperationImpl.java
File metadata and controls
41 lines (33 loc) · 1.33 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
import java.util.*;
public class AtmOperationImpl implements AtmOperationInterf {
ATM atm = new ATM();
Map<Double, String> ministat = new LinkedHashMap<>();
public void viewBalance() {
System.out.println("Available Balance is : " + atm.getBalance());
}
public void withdrawAmount(double withdrawAmount) {
if (withdrawAmount % 500 == 0) {
if (withdrawAmount <= atm.getBalance()) {
ministat.put(withdrawAmount, " Amount Withdrawn");
System.out.println("Collect the cash " + withdrawAmount);
atm.setBalance(atm.getBalance() - withdrawAmount);
viewBalance();
} else {
System.out.println("Insufficient Balance !!");
}
} else {
System.out.println("Plase enter the amount in multiple of 500");
}
}
public void depositAmount(double depositAmount) {
ministat.put(depositAmount, " Amount Deposited");
System.out.println(depositAmount + " Deposited Successfully !!");
atm.setBalance(atm.getBalance() + depositAmount);//updated amount
viewBalance();
}
public void viewMiniStatement() {
for (Map.Entry<Double, String> m : ministat.entrySet()) {
System.out.println(m.getKey() + "" + m.getValue());
}
}
}