Skip to content

Commit 01c9ab3

Browse files
committed
Fix typo errors.
Fix method names errors. Add missing files.
1 parent ab1cb01 commit 01c9ab3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+322
-355
lines changed

Adapter/WildTurkey.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ WildTurkey.prototype.fly = function(){
66
console.log("Fly short distance!");
77
};
88
WildTurkey.prototype.gobble = function(){
9-
console.log("Gooble! Gooble!");
9+
console.log("Gobble! Gobble!");
1010
};

Composite/DinnerMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var DinnerMenu = function(){
2-
Menu.apply(this);
2+
Menu.apply(this);
33
};
44
DinnerMenu.prototype = new Menu();

Composite/Maitress.js

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

Composite/Mattress.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var Mattress = function(aMenus){
2+
this.aMenus = aMenus;
3+
};
4+
Mattress.prototype.printMenu = function(){
5+
this.aMenus.print();
6+
};

Composite/Menu.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
var Menu = function(sName, sDescription){
2-
MenuComponent.apply(this);
1+
var Menu = function(sName, sDescription){
2+
MenuComponent.apply(this);
33
this.aMenuComponents = [];
44
this.sName = sName;
5-
this.sDescription = sDescription;
5+
this.sDescription = sDescription;
66
this.createIterator = function(){
77
throw new Error("This method must be overwritten!");
88
};
@@ -16,15 +16,15 @@ Menu.prototype.remove = function(oMenuComponent){
1616
var nMenuItem = 0;
1717
var nLenMenuItems = this.aMenuComponents.length;
1818
var oItem = null;
19-
20-
for(; nMenuItem < nLenMenuItem;){
19+
20+
for(; nMenuItem < nLenMenuItems;){
2121
oItem = this.aMenuComponents[nMenuItem];
22-
if(oItem !== oMenuItem){
22+
if(oItem !== oMenuComponent){
2323
aMenuItems.push(oItem);
2424
}
25-
nMenuItem = nMenuItem + 1;
25+
nMenuItem = nMenuItem + 1;
2626
}
27-
this.aMenuComponents = aMenuItems;
27+
this.aMenuComponents = aMenuItems;
2828
};
2929
Menu.prototype.getChild = function(nIndex){
3030
return this.aMenuComponents[nIndex];
@@ -38,11 +38,11 @@ Menu.prototype.getDescription = function(){
3838
Menu.prototype.print = function(){
3939
console.log(this.getName() + ": " + this.getDescription());
4040
console.log("--------------------------------------------");
41-
41+
4242
var nMenuComponent = 0;
4343
var nLenMenuComponents = this.aMenuComponents.length;
4444
var oMenuComponent = null;
45-
45+
4646
for(; nMenuComponent < nLenMenuComponents;){
4747
oMenuComponent = this.aMenuComponents[nMenuComponent];
4848
oMenuComponent.print();

Composite/MenuComponent.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ MenuComponent.prototype.isVegetarian = function(){
1515
MenuComponent.prototype.print = function(){
1616
throw new Error("This method must be overwritten!");
1717
};
18-
MenuComponent.prototype.add = function(oComponent){
18+
MenuComponent.prototype.add = function(){
1919
throw new Error("This method must be overwritten!");
2020
};
21-
MenuComponent.prototype.remove = function(oComponent){
21+
MenuComponent.prototype.remove = function(){
2222
throw new Error("This method must be overwritten!");
2323
};
24-
MenuComponent.prototype.getChild = function(nIndex){
24+
MenuComponent.prototype.getChild = function(){
2525
throw new Error("This method must be overwritten!");
2626
};

Composite/index.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
<html>
22
<head>
33
<link type="text/css" rel="stylesheet" href="../css/style.css"/>
4-
<title>Compossite Pattern</title>
4+
<title>Composite Pattern</title>
55
<script type="text/javascript" src="MenuComponent.js"></script>
66
<script type="text/javascript" src="Menu.js"></script>
77
<script type="text/javascript" src="MenuItem.js"></script>
88
<script type="text/javascript" src="DinnerMenu.js"></script>
99
<script type="text/javascript" src="PancakeHouseMenu.js"></script>
1010
<script type="text/javascript" src="CafeMenu.js"></script>
11-
<script type="text/javascript" src="Maitress.js"></script>
11+
<script type="text/javascript" src="Mattress.js"></script>
1212
</head>
1313
<body>
1414
<div id="source">
1515
<h2>Source</h2>
1616
<pre>
1717
var oPanCakeHouseMenu = new Menu("Pancake House Menu", "Breakfast");
1818
var oDinnerMenu = new Menu("Dinner Menu", "Lunch");
19-
var oCoffeMenu = new Menu("Cafe Menu", "Dinner");
19+
var oCoffeeMenu = new Menu("Cafe Menu", "Dinner");
2020
var oAllMenus = new Menu("ALL MENUS", "All menus combined");
2121

2222
oAllMenus.add(oPanCakeHouseMenu);
2323
oAllMenus.add(oDinnerMenu);
2424

2525
oDinnerMenu.add(new MenuItem("Pasta", "Spaghetti with Marinara Sauce, and a slice of sourdough bread", true, 3.89));
26-
oDinnerMenu.add(oCoffeMenu);
26+
oDinnerMenu.add(oCoffeeMenu);
2727

28-
oCoffeMenu.add(new MenuItem("Express", "Coffe from machine", false, 0.99));
28+
oCoffeeMenu.add(new MenuItem("Express", "Coffee from machine", false, 0.99));
2929

30-
var oMaitress = new Maitress(oAllMenus);
31-
oMaitress.printMenu();
30+
var oMattress = new Mattress(oAllMenus);
31+
oMattress.printMenu();
3232
</pre>
3333
</div>
3434
<div id="console">
@@ -40,20 +40,20 @@ <h1>COMPOSITE</h1>
4040
<script type="text/javascript">
4141
var oPanCakeHouseMenu = new Menu("Pancake House Menu", "Breakfast");
4242
var oDinnerMenu = new Menu("Dinner Menu", "Lunch");
43-
var oCoffeMenu = new Menu("Cafe Menu", "Dinner");
43+
var oCoffeeMenu = new Menu("Cafe Menu", "Dinner");
4444
var oAllMenus = new Menu("ALL MENUS", "All menus combined");
4545

4646
oAllMenus.add(oPanCakeHouseMenu);
4747
oAllMenus.add(oDinnerMenu);
4848

4949
oDinnerMenu.add(new MenuItem("Pasta", "Spaghetti with Marinara Sauce, and a slice of sourdough bread", true, 3.89));
50-
oDinnerMenu.add(oCoffeMenu);
50+
oDinnerMenu.add(oCoffeeMenu);
5151

52-
oCoffeMenu.add(new MenuItem("Express", "Coffe from machine", false, 0.99));
52+
oCoffeeMenu.add(new MenuItem("Express", "Coffee from machine", false, 0.99));
5353

54-
var oMaitress = new Maitress(oAllMenus);
54+
var oMattress = new Mattress(oAllMenus);
5555
console.log("---------------------------------------------");
56-
oMaitress.printMenu();
56+
oMattress.printMenu();
5757
console.log("---------------------------------------------");
5858
</script>
5959
</body>

CompositeIterator/1/ConvertToIterator.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ var ConvertToIterator = function(oObject, bStopAutoInit)
1313

1414
this.aArray = oObject;
1515

16-
this.bIsArray = Namespace.Utilities.isArray(this.aArray);
16+
this.bIsArray = this.isArray(this.aArray);
1717

1818
if(!bStopAutoInit)
1919
{
2020
this._setKeysAndLength();
2121
}
2222
};
23+
ConvertToIterator.prototype.isArray = function(aArray)
24+
{
25+
return Object.prototype.toString.call(aArray) === "[object Array]";
26+
};
2327
ConvertToIterator.prototype._setKeysAndLength = function()
2428
{
2529
var sKey = '';

CompositeIterator/1/DinnerMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var DinnerMenu = function(){
2-
Menu.apply(this);
2+
Menu.apply(this);
33
};
44
DinnerMenu.prototype = new Menu();

CompositeIterator/1/Maitress.js

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

0 commit comments

Comments
 (0)