Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adapter - Chaining - Command - Composite - CompositeIterator/1
- Loading branch information
Showing
76 changed files
with
839 additions
and
771 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
### Node template | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git | ||
node_modules | ||
|
||
# Created by .ignore support plugin (hsz.mobi) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Duck { | ||
constructor() {} | ||
|
||
fly() { | ||
throw new Error('This method must be overwritten!'); | ||
} | ||
quack() { | ||
throw new Error('This method must be overwritten!'); | ||
} | ||
} | ||
|
||
export default Duck; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Duck from './Duck'; | ||
|
||
class MallardDuck extends Duck { | ||
fly() { | ||
console.log('Can fly long distances!'); | ||
} | ||
quack() { | ||
console.log('Quack! Quack!'); | ||
} | ||
} | ||
|
||
export default MallardDuck; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Turkey { | ||
fly() { | ||
throw new Error('This method must be overwritten!'); | ||
} | ||
gobble() { | ||
throw new Error('This method must be overwritten'); | ||
} | ||
} | ||
|
||
export default Turkey; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Duck from './Duck'; | ||
|
||
class TurkeyAdapter extends Duck{ | ||
constructor(oTurkey) { | ||
super(oTurkey); | ||
this.oTurkey = oTurkey; | ||
} | ||
fly() { | ||
for(let index = 0, maxFly = 5; index < maxFly; index++) { | ||
this.oTurkey.fly(); | ||
} | ||
} | ||
|
||
quack() { | ||
this.oTurkey.gobble(); | ||
} | ||
} | ||
|
||
export default TurkeyAdapter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Turkey from './Turkey'; | ||
|
||
class WildTurkey extends Turkey { | ||
fly() { | ||
console.log('Fly short distance!'); | ||
} | ||
gobble() { | ||
console.log('Gobble!, Gobble!'); | ||
} | ||
} | ||
|
||
export default WildTurkey; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import MallardDuck from './MallardDuck'; | ||
import WildTurkey from './WildTurkey'; | ||
import TurkeyAdapter from './TurkeyAdapter'; | ||
|
||
let oMallardDuck = new MallardDuck(); | ||
let oWildTurkey = new WildTurkey(); | ||
let oTurkeyAdapter = new TurkeyAdapter(oWildTurkey); | ||
|
||
oMallardDuck.fly(); | ||
oMallardDuck.quack(); | ||
|
||
oWildTurkey.fly(); | ||
oWildTurkey.gobble(); | ||
|
||
oTurkeyAdapter.fly(); | ||
oTurkeyAdapter.quack(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class Chainable { | ||
constructor() { | ||
this.number = 0; | ||
} | ||
|
||
add(number) { | ||
this.number += number; | ||
return this; | ||
} | ||
|
||
multiply(number) { | ||
this.number *= number; | ||
return this; | ||
} | ||
|
||
toString() { | ||
return this.number.toString(); | ||
} | ||
} | ||
|
||
export default Chainable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Chainable from './Chainable'; | ||
|
||
var oChainable = new Chainable(); | ||
// This must return "21" | ||
console.log(oChainable.add(3).add(4).multiply(3).toString()); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.