Skip to content

Commit 9a6a22e

Browse files
committed
Add empty lines for readability
1 parent d6a17f6 commit 9a6a22e

File tree

5 files changed

+18
-0
lines changed

5 files changed

+18
-0
lines changed

JavaScript/1-execute.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class AccountCommand {
55
this.account = account;
66
this.amount = amount;
77
}
8+
89
execute() {
910
throw new Error('Command is not implemented');
1011
}
@@ -33,12 +34,14 @@ class Bank { // Invoker
3334
constructor() {
3435
this.commands = [];
3536
}
37+
3638
operation(account, amount) {
3739
const Command = amount < 0 ? Withdraw : Income;
3840
const command = new Command(account, Math.abs(amount));
3941
command.execute();
4042
this.commands.push(command);
4143
}
44+
4245
showOperations() {
4346
const output = [];
4447
for (const command of this.commands) {

JavaScript/2-undo.js

+7
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ class AccountCommand {
55
this.account = account;
66
this.amount = amount;
77
}
8+
89
execute() {
910
throw new Error('Command.execute() is not implemented');
1011
}
12+
1113
undo() {
1214
throw new Error('Command.undo() is not implemented');
1315
}
@@ -17,6 +19,7 @@ class Withdraw extends AccountCommand {
1719
execute() {
1820
this.account.balance -= this.amount;
1921
}
22+
2023
undo() {
2124
this.account.balance += this.amount;
2225
}
@@ -26,6 +29,7 @@ class Income extends AccountCommand {
2629
execute() {
2730
this.account.balance += this.amount;
2831
}
32+
2933
undo() {
3034
this.account.balance -= this.amount;
3135
}
@@ -42,18 +46,21 @@ class Bank {
4246
constructor() {
4347
this.commands = [];
4448
}
49+
4550
operation(account, amount) {
4651
const Command = amount < 0 ? Withdraw : Income;
4752
const command = new Command(account, Math.abs(amount));
4853
command.execute();
4954
this.commands.push(command);
5055
}
56+
5157
undo(count) {
5258
for (let i = 0; i < count; i++) {
5359
const command = this.commands.pop();
5460
command.undo();
5561
}
5662
}
63+
5764
showOperations() {
5865
const output = [];
5966
for (const command of this.commands) {

JavaScript/3-anemic.js

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Bank {
1919
constructor() {
2020
this.commands = [];
2121
}
22+
2223
operation(account, amount) {
2324
const operation = amount < 0 ? 'Withdraw' : 'Income';
2425
const command = new AccountCommand(
@@ -27,6 +28,7 @@ class Bank {
2728
this.commands.push(command);
2829
account.balance += amount;
2930
}
31+
3032
showOperations() {
3133
console.table(this.commands);
3234
}

JavaScript/4-operations.js

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Bank {
3838
constructor() {
3939
this.commands = [];
4040
}
41+
4142
operation(account, amount) {
4243
const operation = amount < 0 ? 'Withdraw' : 'Income';
4344
const execute = operations[operation];
@@ -55,6 +56,7 @@ class Bank {
5556
this.commands.push(command);
5657
execute(command);
5758
}
59+
5860
showOperations() {
5961
console.table(this.commands);
6062
}

JavaScript/5-undo.js

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class BankAccount {
1414
this.balance = 0;
1515
BankAccount.collection.set(name, this);
1616
}
17+
1718
static find(name) {
1819
return BankAccount.collection.get(name);
1920
}
@@ -48,6 +49,7 @@ class Bank {
4849
constructor() {
4950
this.commands = [];
5051
}
52+
5153
operation(account, amount) {
5254
const operation = amount < 0 ? 'Withdraw' : 'Income';
5355
const { execute } = operations[operation];
@@ -57,6 +59,7 @@ class Bank {
5759
this.commands.push(command);
5860
execute(command);
5961
}
62+
6063
undo(count) {
6164
for (let i = 0; i < count; i++) {
6265
const command = this.commands.pop();
@@ -65,6 +68,7 @@ class Bank {
6568
undo(command);
6669
}
6770
}
71+
6872
showOperations() {
6973
console.table(this.commands);
7074
}

0 commit comments

Comments
 (0)