1
+ let deposit = ( customer , money ) => {
2
+ console . log ( "\n" ) ;
3
+ console . log ( `Got a request from ${ customer . name } to deposit ${ money } Rs` ) ;
4
+ customer . balance += money ;
5
+ console . log ( `Money Deposit Successful for ${ customer . name } ` ) ;
6
+ console . log ( "\n" ) ;
7
+ }
8
+
9
+ let withdrawl = ( customer , money ) => {
10
+ console . log ( "\n" ) ;
11
+ console . log ( `Got a request from ${ customer . name } to Withdrawl ${ money } Rs` ) ;
12
+ if ( customer . balance < money ) {
13
+ console . log ( "Insufficient Balance" ) ;
14
+ console . log ( "\n" ) ;
15
+ }
16
+ else {
17
+ customer . balance -= money ;
18
+ console . log ( `Money Withdrawl Successful for ${ customer . name } ` ) ;
19
+ console . log ( "\n" ) ;
20
+ }
21
+ }
22
+
23
+ let showBalance = ( customer ) => {
24
+ console . log ( "\n" ) ;
25
+ console . log ( `${ customer . name } 's Bank Balance = ${ customer . balance } ` ) ;
26
+ console . log ( "\n" ) ;
27
+ }
28
+
29
+ let bank = ( customer , action , money ) => {
30
+ switch ( action ) {
31
+ case "deposit" :
32
+ deposit ( customer , money ) ;
33
+ break ;
34
+
35
+ case "withdrawl" :
36
+ withdrawl ( customer , money ) ;
37
+ break ;
38
+
39
+ case "showBalance" :
40
+ showBalance ( customer ) ;
41
+ break ;
42
+
43
+ default :
44
+ console . log ( "Invalid Action" ) ;
45
+ break ;
46
+ }
47
+ }
48
+
49
+ let customer1 = { name : "Subhranil" , balance : 5000 } ;
50
+ bank ( customer1 , "showBalance" ) ;
51
+ bank ( customer1 , "deposit" , 4000 ) ;
52
+ bank ( customer1 , "showBalance" ) ;
53
+ bank ( customer1 , "withdrawl" , 3000 ) ;
54
+ bank ( customer1 , "showBalance" ) ;
0 commit comments