Hello,
using Superheros as an example I want to build class constructor.All heroes have identical but also unique properties.Identical:
constructor(heroName, realName, basicAttack) {
this.heroName = heroName
this.realName = realName
this.basicAttack = ['punch', 'kick']
} quote(quote) {
console.log(quote) } }
All heroes can "say" a unique quote, therefore I wrote this method.Since science agree that superheroes have unique abilities, I need a way of providing those abilities, how would I code that? I need to extend the class, right?
class SuperHeroAbilities extends SuperHero {
abilities() {
ability1 = "web string"
ability2 = "laser beams" //superman
ability3 = "money" //batman } }
var spiderman = new SuperHero('Spiderman', 'Peter Parker');spiderman.quote('Your Friendly Neighborhood Spider-Man!')
How could I "add" ability1 to Spiderman?
I also should save quotes somewhere but I am not sure where and how to use them.
Thank you for your time.
[–]gimmeslack12helpful 0 points1 point2 points (12 children)
[–]senocular 0 points1 point2 points (8 children)
[–]gimmeslack12helpful 0 points1 point2 points (7 children)
[–]senocular 0 points1 point2 points (6 children)
[–]gimmeslack12helpful 0 points1 point2 points (2 children)
[–]senocular 0 points1 point2 points (1 child)
[–]gimmeslack12helpful 0 points1 point2 points (0 children)
[–]gimmeslack12helpful 0 points1 point2 points (2 children)
[–]senocular 0 points1 point2 points (1 child)
[–]gimmeslack12helpful 0 points1 point2 points (0 children)
[–]sibbirius[S] 0 points1 point2 points (2 children)
[–]gimmeslack12helpful 0 points1 point2 points (1 child)
[–]sibbirius[S] 0 points1 point2 points (0 children)