Created
June 18, 2016 16:48
-
-
Save rrgarciach/011bee078497c35cb609c53456353c21 to your computer and use it in GitHub Desktop.
This is the mediator guy ;D
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
function Plane(planeName) { | |
this.planeName = planeName; | |
this.isFlying = false; | |
this.takeOff = function (track) { | |
if (track) { | |
if(!isFlying) { | |
track = false; | |
isFlying = true; | |
return; | |
} | |
console.log('Plane ' + planeName + ' is already flying.'); | |
return; | |
} | |
console.log('Selected track is not clear.'); | |
} | |
this.land = function (track) { | |
if (track) { | |
if(isFlying) { | |
track = false; | |
isFlying = false; | |
return; | |
} | |
console.log('Plane ' + planeName + ' is already landed.'); | |
return; | |
} | |
console.log('Selected track is not clear.'); | |
} | |
} | |
// This is the mediator guy ;D | |
(function () { | |
var track1 = true; | |
var track2 = true; | |
var plane401 = new Plane(401); | |
var plane707 = new Plane(707); | |
var plane111 = new Plane(111); | |
var plane69 = new Plane(69); | |
plane69.takeOff(track1); | |
plane111.takeOff(track2); | |
track1 = true; | |
plane401.takeOff(track1); | |
track2 = true; | |
plane111.land(track2); | |
track1 = true; | |
plane69.land(track1); | |
track2 = true; | |
plane111.takeOff(track2); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment