-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAtmOperationImpl.java
More file actions
42 lines (38 loc) · 1.48 KB
/
AtmOperationImpl.java
File metadata and controls
42 lines (38 loc) · 1.48 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
import java.util.HashMap;
import java.util.Map;
public class AtmOperationImpl implements AtmOperationInterf {
ATM atm=new ATM();
Map<Double, String> ministmt = new HashMap<>();
@Override
public void viewBalance() {
System.out.println("Available Balance is: " + atm.getBalance());
}
@Override
public void withdrawAmount(double withdrawAmount) {
if(withdrawAmount%100==0 || withdrawAmount%200==0 || withdrawAmount%500==0 || withdrawAmount%2000==0){
if(atm.getBalance() > withdrawAmount){
ministmt.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("Please enter the amount in Multiple of 100,200,500 or 2000!");
}
}
@Override
public void depositAmount(double depositAmount) {
ministmt.put(depositAmount,"Amount Deposited");
System.out.println(depositAmount+" Deposited Successfully!!");
atm.setBalance(atm.getBalance() + depositAmount);
viewBalance();
}
@Override
public void viewMiniStatement() {
for(Map.Entry<Double,String> m:ministmt.entrySet()){
System.out.println(m.getKey()+" "+m.getValue());
}
}
}