Last active
December 20, 2015 22:09
-
-
Save akkerman/6202454 to your computer and use it in GitHub Desktop.
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
Object.prototype.mixin = (aClass) -> | |
for key, value of aClass | |
@[key] = value | |
for key, value of aClass.prototype | |
@::[key] = value | |
@ | |
class Voertuig | |
constructor: (@naam, @snelheid=0)-> | |
getNaam: => @naam | |
getSnelheid: => @snelheid | |
setSnelheid: (@snelheid) => | |
class Auto extends Voertuig | |
constructor: (naam, snelheid=0) -> | |
super(naam, snelheid) | |
rij: => console.log(@naam + " rijdt") | |
class Boot extends Voertuig | |
constructor: (naam, snelheid=0) -> | |
super(naam, snelheid) | |
vaar: => console.log(@naam + " vaart") | |
class Amfibie extends Voertuig | |
@mixin Boot | |
@mixin Auto | |
constructor: (naam, snelheid=0) -> | |
super(naam, snelheid) | |
a = new Amfibie("Hovercraft", 120) | |
console.log(a.getNaam()) | |
a.rij() | |
a.vaar() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment