TIL) Sprint-beesbeesbees

omegle·2022년 9월 22일
0
post-thumbnail

1. 스프린트 내용

Class Structure
├── Grub
│ └── Bee
│ ├── HoneyMakerBee
│ └── ForagerBee

2. 풀이과정

<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;

3. 스프린트를 통해 배운점

  1. 클래스와 인스턴스라는 용어를 이해할 수 있다.
  2. new 키워드의 사용법을 이해할 수 있다.
  3. class 키워드의 사용법을 이해할 수 있다.
  4. 현실 세계의 모델을 바탕으로 클래스의 메소드와 속성을 디자인할 수 있다.
  5. 객체 지향 프로그래밍의 상속(Inheritance)의 개념을 이해하고 코드로 작성할 수 있다.
  6. 상속관계를 가진 현실 세계의 모델을 코드로 작성할 수 있다.
  7. 클래스 상속의 원리를 이해할 수 있다.
profile
JANG EUN JI | 장은지

0개의 댓글