Skip to content

Commit 4b9ed04

Browse files
committed
Move code to ES2015
- Adapter - Chaining - Command - Composite - CompositeIterator/1 - CompositeIterator/2
1 parent c2f86b5 commit 4b9ed04

27 files changed

+442
-452
lines changed

CompositeIterator/1/scripts/ConvertToIterator.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
function getIndexArray(instance) {
2-
return instance.lastIndex;
1+
function getIndexArray() {
2+
return this.lastIndex;
33
}
4-
function getIndexObject(instance) {
5-
return instance.keys[instance.lastIndex];
4+
function getIndexObject() {
5+
return this.keys[this.lastIndex];
66
}
77

8-
function getCurrentArray(instance) {
9-
return instance.array[this.lastIndex];
8+
function getCurrentArray() {
9+
return this.array[this.lastIndex];
1010
}
1111

12-
function getCurrentObject(instance) {
13-
return instance.array[instance.keys[instance.lastIndex]];
12+
function getCurrentObject() {
13+
return this.array[this.keys[this.lastIndex]];
1414
}
1515

16-
function nextArray(instance) {
16+
function nextArray() {
1717
var result = null;
18-
if (instance.hasNext()) {
19-
result = instance.array[++instance.lastIndex];
18+
if (this.hasNext()) {
19+
result = this.array[++this.lastIndex];
2020
}
2121
return result;
2222
}
2323

24-
function nextObject(instance) {
24+
function nextObject() {
2525
var result = null;
26-
if (instance.hasNext()) {
27-
result = instance.array[instance.keys[++instance.lastIndex]];
26+
if (this.hasNext()) {
27+
result = this.array[this.keys[++this.lastIndex]];
2828
}
2929
return result;
3030
}
3131

32-
function prevArray(instance) {
32+
function prevArray() {
3333
var result = null;
34-
if (instance.hasPrev()) {
35-
result = instance.array[--instance.lastIndex];
34+
if (this.hasPrev()) {
35+
result = this.array[--this.lastIndex];
3636
}
3737
return result;
3838
}
3939

40-
function prevObject(instance) {
40+
function prevObject() {
4141
var result = null;
42-
if (instance.hasPrev()) {
43-
result = instance.array[instance.keys[--instance.lastIndex]];
42+
if (this.hasPrev()) {
43+
result = this.array[this.keys[--this.lastIndex]];
4444
}
4545
return result;
4646
}

CompositeIterator/1/scripts/Menu.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Menu extends MenuComponent {
3131
return this.description;
3232
}
3333
print() {
34+
debugger;
3435
console.log(this.getName() + ": " + this.getDescription());
3536
console.log("--------------------------------------------");
3637

CompositeIterator/1/scripts/MenuItem.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ class MenuItem extends MenuComponent {
1010
this.price = price;
1111
}
1212
getName() {
13-
return this.sName;
13+
return this.name;
1414
}
1515
getDescription() {
16-
return this.sDescription;
16+
return this.description;
1717
}
1818
getPrice() {
19-
return this.nPrice;
19+
return this.price;
2020
}
2121
isVegetarian() {
22-
return this.bVegetarian;
22+
return this._isVegetarian;
2323
}
2424
print() {
2525
console.log(this.getName() + ": " + this.getDescription() + ", " + this.getPrice() + "euros");

CompositeIterator/2/CafeMenu.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

CompositeIterator/2/CompositeIterator.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

CompositeIterator/2/ConvertToIterator.js

Lines changed: 0 additions & 184 deletions
This file was deleted.

CompositeIterator/2/DinnerMenu.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

CompositeIterator/2/Iterator.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

CompositeIterator/2/Mattress.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)