File tree 6 files changed +26
-34
lines changed
6 files changed +26
-34
lines changed Original file line number Diff line number Diff line change @@ -37,9 +37,9 @@ class Bank {
37
37
this . commands = [ ] ;
38
38
}
39
39
40
- operation ( account , amount ) {
41
- const Command = amount < 0 ? Withdraw : Income ;
42
- const command = new Command ( account , Math . abs ( amount ) ) ;
40
+ operation ( account , value ) {
41
+ const Command = value < 0 ? Withdraw : Income ;
42
+ const command = new Command ( account , Math . abs ( value ) ) ;
43
43
command . execute ( ) ;
44
44
this . commands . push ( command ) ;
45
45
}
Original file line number Diff line number Diff line change @@ -47,9 +47,9 @@ class Bank {
47
47
this . commands = [ ] ;
48
48
}
49
49
50
- operation ( account , amount ) {
51
- const Command = amount < 0 ? Withdraw : Income ;
52
- const command = new Command ( account , Math . abs ( amount ) ) ;
50
+ operation ( account , value ) {
51
+ const Command = value < 0 ? Withdraw : Income ;
52
+ const command = new Command ( account , Math . abs ( value ) ) ;
53
53
command . execute ( ) ;
54
54
this . commands . push ( command ) ;
55
55
}
Original file line number Diff line number Diff line change @@ -20,13 +20,11 @@ class Bank {
20
20
this . commands = [ ] ;
21
21
}
22
22
23
- operation ( account , amount ) {
24
- const operation = amount < 0 ? 'withdraw' : 'income' ;
25
- const command = new AccountCommand (
26
- operation ,
27
- account . name ,
28
- Math . abs ( amount ) ,
29
- ) ;
23
+ operation ( account , value ) {
24
+ const operation = value < 0 ? 'withdraw' : 'income' ;
25
+ const amount = Math . abs ( value ) ;
26
+ const { name } = account ;
27
+ const command = new AccountCommand ( operation , name , amount ) ;
30
28
this . commands . push ( command ) ;
31
29
account . balance += amount ;
32
30
}
Original file line number Diff line number Diff line change @@ -39,14 +39,12 @@ class Bank {
39
39
this . commands = [ ] ;
40
40
}
41
41
42
- operation ( account , amount ) {
43
- const operation = amount < 0 ? 'withdraw' : 'income' ;
42
+ operation ( account , value ) {
43
+ const operation = value < 0 ? 'withdraw' : 'income' ;
44
44
const execute = OPERATIONS [ operation ] ;
45
- const command = new AccountCommand (
46
- operation ,
47
- account . name ,
48
- Math . abs ( amount ) ,
49
- ) ;
45
+ const amount = Math . abs ( value ) ;
46
+ const { name } = account ;
47
+ const command = new AccountCommand ( operation , name , amount ) ;
50
48
const check = OPERATIONS . allowed ;
51
49
const allowed = check ( command ) ;
52
50
if ( ! allowed ) {
Original file line number Diff line number Diff line change @@ -50,14 +50,12 @@ class Bank {
50
50
this . commands = [ ] ;
51
51
}
52
52
53
- operation ( account , amount ) {
54
- const operation = amount < 0 ? 'withdraw' : 'income' ;
53
+ operation ( account , value ) {
54
+ const operation = value < 0 ? 'withdraw' : 'income' ;
55
55
const { execute } = OPERATIONS [ operation ] ;
56
- const command = new AccountCommand (
57
- operation ,
58
- account . name ,
59
- Math . abs ( amount ) ,
60
- ) ;
56
+ const amount = Math . abs ( value ) ;
57
+ const { name } = account ;
58
+ const command = new AccountCommand ( operation , name , amount ) ;
61
59
this . commands . push ( command ) ;
62
60
execute ( command ) ;
63
61
}
Original file line number Diff line number Diff line change @@ -36,14 +36,12 @@ class Bank {
36
36
this . commands = [ ] ;
37
37
}
38
38
39
- operation ( account , amount ) {
40
- const operation = amount < 0 ? 'withdraw' : 'income' ;
39
+ operation ( account , value ) {
40
+ const operation = value < 0 ? 'withdraw' : 'income' ;
41
41
const { execute } = OPERATIONS [ operation ] ;
42
- const command = {
43
- operation,
44
- account : account . name ,
45
- amount : Math . abs ( amount ) ,
46
- } ;
42
+ const amount = Math . abs ( value ) ;
43
+ const { name } = account ;
44
+ const command = { operation, account : name , amount } ;
47
45
this . commands . push ( command ) ;
48
46
execute ( command ) ;
49
47
}
You can’t perform that action at this time.
0 commit comments