Skip to content

Commit

Permalink
- Refactor name of internal folders.
Browse files Browse the repository at this point in the history
- Add gulp tasks to transpile all the ES6 files to ES5.
  • Loading branch information
tcorral committed Apr 24, 2016
1 parent 2c54ccd commit 6a64876
Show file tree
Hide file tree
Showing 52 changed files with 208 additions and 83 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions Composite/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ <h2>Source</h2>
import Mattress from './Mattress';

let oPanCakeHouseMenu = new Menu("Pancake House Menu", "Breakfast");
let oDinnerMenu = new Menu("Dinner Menu", "Lunch");
let oCoffeeMenu = new Menu("Cafe Menu", "Dinner");
let oLunchMenu = new Menu("Dinner Menu", "Lunch");
let oCoffeeMenu = new Menu("Cafe Menu", "Lunch");
let oAllMenus = new Menu("ALL MENUS", "All menus combined");

oAllMenus.add(oPanCakeHouseMenu);
oAllMenus.add(oDinnerMenu);
oAllMenus.add(oLunchMenu);

oDinnerMenu.add(new MenuItem("Pasta", "Spaghetti with Marinara Sauce, and a slice of sourdough bread", true, 3.89));
oDinnerMenu.add(oCoffeeMenu);
oLunchMenu.add(new MenuItem("Pasta", "Spaghetti with Marinara Sauce, and a slice of sourdough bread", true, 3.89));
oLunchMenu.add(oCoffeeMenu);

oCoffeeMenu.add(new MenuItem("Express", "Coffee from machine", false, 0.99));

Expand Down
5 changes: 0 additions & 5 deletions Composite/scripts/DinnerMenu.js

This file was deleted.

5 changes: 5 additions & 0 deletions Composite/scripts/LunchMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Menu from './Menu';

class LunchMenu extends Menu {}

export default LunchMenu;
8 changes: 4 additions & 4 deletions Composite/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import MenuItem from './MenuItem';
import Mattress from './Mattress';

let oPanCakeHouseMenu = new Menu("Pancake House Menu", "Breakfast");
let oDinnerMenu = new Menu("Dinner Menu", "Lunch");
let oLunchMenu = new Menu("Lunch Menu", "Lunch");
let oCoffeeMenu = new Menu("Cafe Menu", "Dinner");
let oAllMenus = new Menu("ALL MENUS", "All menus combined");

oAllMenus.add(oPanCakeHouseMenu);
oAllMenus.add(oDinnerMenu);
oAllMenus.add(oLunchMenu);

oDinnerMenu.add(new MenuItem("Pasta", "Spaghetti with Marinara Sauce, and a slice of sourdough bread", true, 3.89));
oDinnerMenu.add(oCoffeeMenu);
oLunchMenu.add(new MenuItem("Pasta", "Spaghetti with Marinara Sauce, and a slice of sourdough bread", true, 3.89));
oLunchMenu.add(oCoffeeMenu);

oCoffeeMenu.add(new MenuItem("Express", "Coffee from machine", false, 0.99));

Expand Down
10 changes: 5 additions & 5 deletions CompositeIterator/1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ <h2>Source</h2>
import Mattress from '../../common/Mattress';

var oPanCakeHouseMenu = new Menu("Pancake House Menu", "Breakfast");
var oDinnerMenu = new Menu("Dinner Menu", "Lunch");
var oCoffeeMenu = new Menu("Cafe Menu", "Dinner");
var oLunchMenu = new Menu("Lunch Menu", "Lunch");
var oCoffeeMenu = new Menu("Cafe Menu", "Lunch");
var oAllMenus = new Menu("ALL MENUS", "All menus combined");

oAllMenus.add(oPanCakeHouseMenu);
oAllMenus.add(oDinnerMenu);
oAllMenus.add(oLunchMenu);

oDinnerMenu.add(new MenuItem("Pasta",
oLunchMenu.add(new MenuItem("Pasta",
"Spaghetti with Marinara Sauce, and a slice of sourdough bread",
true,
3.89));
oDinnerMenu.add(oCoffeeMenu);
oLunchMenu.add(oCoffeeMenu);

oCoffeeMenu.add(new MenuItem("Express", "Coffee from machine", false, 0.99));

Expand Down
10 changes: 5 additions & 5 deletions CompositeIterator/1/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import MenuItem from '../../common/MenuItem';
import Mattress from '../../common/Mattress';

var oPanCakeHouseMenu = new Menu("Pancake House Menu", "Breakfast");
var oDinnerMenu = new Menu("Dinner Menu", "Lunch");
var oCoffeeMenu = new Menu("Cafe Menu", "Dinner");
var oLunchMenu = new Menu("Dinner Menu", "Lunch");
var oCoffeeMenu = new Menu("Cafe Menu", "Lunch");
var oAllMenus = new Menu("ALL MENUS", "All menus combined");

oAllMenus.add(oPanCakeHouseMenu);
oAllMenus.add(oDinnerMenu);
oAllMenus.add(oLunchMenu);

oDinnerMenu.add(new MenuItem("Pasta",
oLunchMenu.add(new MenuItem("Pasta",
"Spaghetti with Marinara Sauce, and a slice of sourdough bread",
true,
3.89));
oDinnerMenu.add(oCoffeeMenu);
oLunchMenu.add(oCoffeeMenu);

oCoffeeMenu.add(new MenuItem("Express", "Coffee from machine", false, 0.99));

Expand Down
8 changes: 4 additions & 4 deletions CompositeIterator/2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ <h2>Source</h2>
import Mattress from './Mattress';

let panCakeHouseMenu = new Menu("Pancake House Menu", "Breakfast");
let dinnerMenu = new Menu("Dinner Menu", "Lunch");
let lunchMenu = new Menu("Lunch Menu", "Lunch");
let coffeeMenu = new Menu("Cafe Menu", "Dinner");
let allMenus = new Menu("ALL MENUS", "All menus combined");

allMenus.add(panCakeHouseMenu);
allMenus.add(dinnerMenu);
allMenus.add(lunchMenu);

dinnerMenu.add(new MenuItem("Pasta",
lunchMenu.add(new MenuItem("Pasta",
"Spaghetti with Marinara Sauce, and a slice of sourdough bread",
true,
3.89));
dinnerMenu.add(coffeeMenu);
lunchMenu.add(coffeeMenu);


coffeeMenu.add(new MenuItem("Express", "Coffee from machine", false, 0.99));
Expand Down
10 changes: 5 additions & 5 deletions CompositeIterator/2/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import MenuItem from '../../common/MenuItem';
import Mattress from './Mattress';

let panCakeHouseMenu = new Menu("Pancake House Menu", "Breakfast");
let dinnerMenu = new Menu("Dinner Menu", "Lunch");
let coffeeMenu = new Menu("Cafe Menu", "Dinner");
let lunchMenu = new Menu("Dinner Menu", "Lunch");
let coffeeMenu = new Menu("Cafe Menu", "Lunch");
let allMenus = new Menu("ALL MENUS", "All menus combined");

allMenus.add(panCakeHouseMenu);
allMenus.add(dinnerMenu);
allMenus.add(lunchMenu);

dinnerMenu.add(new MenuItem("Pasta",
lunchMenu.add(new MenuItem("Pasta",
"Spaghetti with Marinara Sauce, and a slice of sourdough bread",
true,
3.89));
dinnerMenu.add(coffeeMenu);
lunchMenu.add(coffeeMenu);


coffeeMenu.add(new MenuItem("Express", "Coffee from machine", false, 0.99));
Expand Down
5 changes: 0 additions & 5 deletions CompositeIterator/common/DinnerMenu.js

This file was deleted.

5 changes: 5 additions & 0 deletions CompositeIterator/common/LunchMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Menu from './Menu';

class LunchMenu extends Menu {}

export default LunchMenu;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Menu from './Menu';
import MenuItem from './MenuItem';
const MAX_ITEMS = 6;

class DinnerMenu extends Menu {
class LunchMenu extends Menu {
constructor() {
super();
this.addItem("Vegetarian BLT", "(Fakin') Bacon with lettuce and tomato on whole wheat", true, 2.99);
Expand All @@ -24,4 +24,4 @@ class DinnerMenu extends Menu {
}
}

export default DinnerMenu;
export default LunchMenu;
4 changes: 2 additions & 2 deletions Iterator/1/scripts/Mattress.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PancakeHouseMenu from './PancakeHouseMenu';
import DinnerMenu from './DinnerMenu';
import LunchMenu from './LunchMenu';

function processArray(array, callback) {
for (let item of array) {
Expand All @@ -26,7 +26,7 @@ function printEachVegetarianMenu(array, name) {
class Mattress {
constructor() {
this.breakfastItems = new PancakeHouseMenu().getMenuItems();
this.lunchItems = new DinnerMenu().getMenuItems();
this.lunchItems = new LunchMenu().getMenuItems();
}

printBreakfastMenu() {
Expand Down
6 changes: 3 additions & 3 deletions Iterator/2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ <h2>Source</h2>
<pre>
import Mattress from './Mattress';
import PancakeHouseMenu from './PancakeHouseMenu';
import DinnerMenu from './DinnerMenu';
import LunchMenu from './LunchMenu';

let oMattress = new Mattress({
pancakeHouseMenu: new PancakeHouseMenu(),
dinnerMenu: new DinnerMenu()
lunchMenu: new LunchMenu()
});
console.log("---------------------------------------------");
oMattress.printMenu();
console.log("---------------------------------------------");
oMattress.printBreakfastMenu();
console.log("---------------------------------------------");
oMattress.printDinnerMenu();
oMattress.printLunchMenu();
</pre>
</div>
<div id="console">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Iterator from '../../common/Iterator';

const MAX_ITEMS = 6;

class DinnerMenu extends Menu {
class LunchMenu extends Menu {
constructor() {
super();
this.addItem("Vegetarian BLT", "(Fakin') Bacon with lettuce and tomato on whole wheat", true, 2.99);
Expand All @@ -25,4 +25,4 @@ class DinnerMenu extends Menu {
}
}

export default DinnerMenu;
export default LunchMenu;
18 changes: 9 additions & 9 deletions Iterator/2/scripts/Mattress.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ function printMenu(iterator) {
class Mattress {
constructor(menus) {
this.pancakeHouseMenu = menus.pancakeHouseMenu;
this.dinnerMenu = menus.dinnerMenu;
this.lunchMenu = menus.lunchMenu;
}

printMenu() {
this.printBreakfastMenu();
this.printDinnerMenu()
this.printLunchMenu()
}

printBreakfastMenu() {
Expand All @@ -22,15 +22,15 @@ class Mattress {
printMenu(iteratorPancakeHouseMenu);
}

printDinnerMenu() {
let iteratorDinnerMenu = this.dinnerMenu.createIterator();
console.log('Dinner');
printMenu(iteratorDinnerMenu);
printLunchMenu() {
let iteratorLunchMenu = this.lunchMenu.createIterator();
console.log('Lunch');
printMenu(iteratorLunchMenu);
}

isItemVegearian(name) {
let iteratorPancakeHouseMenu = this.pancakeHouseMenu.createIterator();
let iteratorDinnerMenu = this.dinnerMenu.createIterator();
let iteratorLunchMenu = this.lunchMenu.createIterator();
let menuItem = iteratorPancakeHouseMenu.next();

while (menuItem.value) {
Expand All @@ -40,13 +40,13 @@ class Mattress {
menuItem = iteratorPancakeHouseMenu.next();
}

menuItem = iteratorDinnerMenu.next();
menuItem = iteratorLunchMenu.next();

while (menuItem.value) {
if (menuItem.value.name === name) {
return menuItem.value.isVegetarian();
}
menuItem = iteratorDinnerMenu.next();
menuItem = iteratorLunchMenu.next();
}
throw new Error("Sorry, but we don't have this in our menu!");
}
Expand Down
6 changes: 3 additions & 3 deletions Iterator/2/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Mattress from './Mattress';
import PancakeHouseMenu from './PancakeHouseMenu';
import DinnerMenu from './DinnerMenu';
import LunchMenu from './LunchMenu';

let oMattress = new Mattress({
pancakeHouseMenu: new PancakeHouseMenu(),
dinnerMenu: new DinnerMenu()
lunchMenu: new LunchMenu()
});
console.log("---------------------------------------------");
oMattress.printMenu();
console.log("---------------------------------------------");
oMattress.printBreakfastMenu();
console.log("---------------------------------------------");
oMattress.printDinnerMenu();
oMattress.printLunchMenu();
6 changes: 3 additions & 3 deletions Iterator/3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ <h2>Source</h2>
<pre>
import Mattress from './Mattress';
import PancakeHouseMenu from './PancakeHouseMenu';
import DinnerMenu from './DinnerMenu';
import LunchMenu from './LunchMenu';

var oMattress = new Mattress({
pancakeHouseMenu: new PancakeHouseMenu(),
dinnerMenu: new DinnerMenu()
lunchMenu: new LunchMenu()
});
console.log("---------------------------------------------");
oMattress.printMenu();
console.log("---------------------------------------------");
oMattress.printBreakfastMenu();
console.log("---------------------------------------------");
oMattress.printDinnerMenu();
oMattress.printLunchMenu();
</pre>
</div>
<div id="console">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import MenuItem from '../../common/MenuItem';

const MAX_ITEMS = 6;

class DinnerMenu extends Menu {
class LunchMenu extends Menu {
constructor() {
super();
this.addItem("Vegetarian BLT", "(Fakin') Bacon with lettuce and tomato on whole wheat", true, 2.99);
Expand All @@ -23,4 +23,4 @@ class DinnerMenu extends Menu {
}
}

export default DinnerMenu;
export default LunchMenu;
18 changes: 9 additions & 9 deletions Iterator/3/scripts/Mattress.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ function printMenu(iterator) {
class Mattress {
constructor(menus) {
this.pancakeHouseMenu = menus.pancakeHouseMenu;
this.dinnerMenu = menus.dinnerMenu;
this.lunchMenu = menus.lunchMenu;
}
printMenu() {
this.printBreakfastMenu();
this.printDinnerMenu();
this.printLunchMenu();
}
printBreakfastMenu() {
var iteratorPancakeHouseMenu = this.pancakeHouseMenu.createIterator();
console.log("Breakfast");
printMenu(iteratorPancakeHouseMenu);
}
printDinnerMenu() {
var iteratorDinnerMenu = this.dinnerMenu.createIterator();
console.log("Dinner");
printMenu(iteratorDinnerMenu);
printLunchMenu() {
var iteratorLunchMenu = this.lunchMenu.createIterator();
console.log("Lunch");
printMenu(iteratorLunchMenu);
}
isItemVegetarian(name) {
var iteratorPancakeHouseMenu = this.pancakeHouseMenu.createIterator();
var iteratorDinnerMenu = this.dinnerMenu.createIterator();
var iteratorLunchMenu = this.lunchMenu.createIterator();
let menuItem = iteratorPancakeHouseMenu.next();

while(menuItem.value) {
Expand All @@ -37,13 +37,13 @@ class Mattress {
}
}

menuItem = iteratorDinnerMenu.next();
menuItem = iteratorLunchMenu.next();

while(menuItem.value) {
if(menuItem.value.name === name) {
return menuItem.value.isVegetarian();
}
menuItem = iteratorDinnerMenu.next();
menuItem = iteratorLunchMenu.next();
}

throw new Error("Sorry, but we don't have this in our menu!");
Expand Down
Loading

0 comments on commit 6a64876

Please sign in to comment.