-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path117. BankingApplication.js
54 lines (47 loc) · 1.42 KB
/
117. BankingApplication.js
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
let deposit = (customer, money) => {
console.log("\n");
console.log(`Got a request from ${customer.name} to deposit ${money}Rs`);
customer.balance += money;
console.log(`Money Deposit Successful for ${customer.name}`);
console.log("\n");
}
let withdrawl = (customer, money) => {
console.log("\n");
console.log(`Got a request from ${customer.name} to Withdrawl ${money}Rs`);
if (customer.balance < money) {
console.log("Insufficient Balance");
console.log("\n");
}
else {
customer.balance -= money;
console.log(`Money Withdrawl Successful for ${customer.name}`);
console.log("\n");
}
}
let showBalance = (customer) => {
console.log("\n");
console.log(`${customer.name}'s Bank Balance = ${customer.balance}`);
console.log("\n");
}
let bank = (customer, action, money) => {
switch (action) {
case "deposit":
deposit(customer, money);
break;
case "withdrawl":
withdrawl(customer, money);
break;
case "showBalance":
showBalance(customer);
break;
default:
console.log("Invalid Action");
break;
}
}
let customer1 = {name: "Subhranil", balance: 5000};
bank(customer1, "showBalance");
bank(customer1, "deposit", 4000);
bank(customer1, "showBalance");
bank(customer1, "withdrawl", 3000);
bank(customer1, "showBalance");