Class Structure
├── Grub
│ └── Bee
│ ├── HoneyMakerBee
│ └── ForagerBee
<Bee.js>
const Grub = require('./Grub');
class Bee extends Grub {
constructor(){
super();
this.age= 5;
this.color= 'yellow';
this.job = 'Keep on growing';
}
// TODO..
}
module.exports = Bee;
const Bee = require('./Bee');
class ForagerBee extends Bee {
constructor(){
super();
this.age = 10;
this.job = 'find pollen';
this.canFly = true;
this.treasureChest = [];
}
forage(보물){
this.treasureChest.push(보물);
}
// TODO..
}
module.exports = ForagerBee;
<Grub.js>
class Grub {
constructor(){
this.age = 0;
this.color= 'pink';
this.food='jelly';
}
eat(){
return 'Mmmmmmmmm jelly'
}
// TODO..
}
module.exports = Grub;
<HoneyMakerBee.js>
const Bee = require('./Bee');
class HoneyMakerBee extends Bee {
constructor(){
super();
this.age = 10;
this.job = 'make honey';
this.honeyPot = 0;
}
makeHoney(){
this.honeyPot+=1
}
giveHoney(){
this.honeyPot-=1
}
// TODO..
}
module.exports = HoneyMakerBee;