Created
July 10, 2019 17:13
-
-
Save kettanaito/30779f8dc220fa7bd328d8bcef5e58d2 to your computer and use it in GitHub Desktop.
OOP
This file contains hidden or 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
class Guitar { | |
constructor(args) { | |
this.name = args.name; | |
this.stringsCount = args.stringsCount || 6; | |
} | |
play() { | |
console.log("lalala"); | |
} | |
} | |
class BassGuitar extends Guitar { | |
constructor(bassArgs) { | |
super(bassArgs); | |
this.stringsCount = 4; | |
} | |
slap() { | |
console.log("yey baby"); | |
} | |
} | |
// | |
const gipsone = new Guitar({ | |
name: "bob" | |
}); | |
const hope = new Guitar({ | |
name: "hope", | |
stringsCount: 12 | |
}); | |
const coolBass = new BassGuitar({ | |
name: "cool", | |
}); | |
console.log(gipsone); | |
console.log(hope); | |
console.log(coolBass); | |
console.log(coolBass.play()); | |
console.log(coolBass.slap()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment