[C/F TIL] 23일차 - 프로토타입, 페어과제, beesbeesbees

mu-eng·2023년 5월 12일

TIL (in boost camp)

목록 보기
24/53
post-thumbnail

Code States
Front-end boost camp
Today
I
Learned

🐬 5월 12일 금요일 23일차 수업 시작


🐬 페어 프로그래밍

오늘은 어제 배운 클래스, 프로토타입 이론 공부(링크: https://bit.ly/3pwV3V1)에 이어 오늘은 클래스와 프로토타입을 익혀볼 수 있는 페어 과제를 진해했다. 난이도는 어렵진 않았다.!


1) Grub class functionality - 완료
✓ age 속성은 0이어야 합니다
✓ color 속성은 pink이어야 합니다
✓ food 속성은 jelly이어야 합니다
✓ eat 메서드가 존재해야 합니다
✓ eat 메서드는 Mmmmmmmmm jelly를 리턴합니다.

class Grub {
  // TODO..
}

module.exports = Grub;
class Grub {
  // TODO..
  constructor (age, color, food) {
    this.age = 0;
    this.color = 'pink';
    this.food = 'jelly';
  }

  eat() {
    return 'Mmmmmmmmm jelly';
  }
}

module.exports = Grub;

2) Bee class functionality
✓ age 속성은 5이어야 합니다
✓ color 속성은 yellow이어야 합니다
✓ food 속성은 Grub으로부터 상속받습니다
✓ eat 메서드는 Grub으로부터 상속받습니다
✓ job 속성은 Keep on growing이어야 합니다

const Grub = require('./1-Grub');

class Bee {
  // TODO..
}

module.exports = Bee;
const Grub = require('./1-Grub');

class Bee extends Grub {
  // TODO..
  constructor (age, color, job) {
    super();
    
    this.age = 5;
    this.color = "yellow";
    this.job = "Keep on growing";
  }
}


module.exports = Bee;

3) ForagerBee class functionality
✓ age 속성은 10이어야 합니다
✓ job 속성은 find pollen이어야 합니다
✓ color 속성은 Bee로부터 상속받습니다
✓ food 속성은 Grub으로부터 상속받습니다
✓ eat 메서드는 Grub으로부터 상속받습니다
✓ canFly 속성은 true이어야 합니다
✓ treasureChest 속성은 빈 배열 []이어야 합니다
✓ forage 메서드를 통해 treasureChest 속성에 보물을 추가할 수 있어야 합니다

const Bee = require('./2-Bee');

class ForagerBee {
  // TODO..
}

module.exports = ForagerBee;
const Bee = require('./2-Bee');

class ForagerBee extends Bee {
  // TODO..
  constructor (age, job, canFly, treasureChest) {
    super();

    this.age = 10;
    this.job = 'find pollen';
    this.canFly = true;
    this.treasureChest = [];
  }

  forage(treasure) {
    this.treasureChest.push(treasure);
  }
}

module.exports = ForagerBee;

4) HoneyMakerBee class functionality
✓ age 속성은 10이어야 합니다
✓ job 속성은 make honey이어야 합니다
✓ color 속성은 Bee로부터 상속받습니다
✓ food 속성은 Grub으로부터 상속받습니다
✓ eat 메서드는 Grub으로부터 상속받습니다
✓ honeyPot 속성은 0이어야 합니다
✓ makeHoney 메서드는 honeyPot에 1씩 추가합니다
✓ giveHoney 메서드는 honeyPot에 1씩 뺍니다

const Bee = require('./2-Bee');

class HoneyMakerBee {
  // TODO..
}

module.exports = HoneyMakerBee;
const Bee = require('./2-Bee');

class HoneyMakerBee extends Bee {
  // TODO..
  constructor (age, job, honeyPot) {
    super();

    this.age = 10;
    this.job = 'make honey';
    this.honeyPot = 0;
  }

  makeHoney() {
    this.honeyPot = this.honeyPot + 1;
  }
  
  giveHoney() {
    this.honeyPot = this.honeyPot - 1;
  }
}

module.exports = HoneyMakerBee;

🐬 23일차 수업을 마치며...

오늘 과제는 어렵지 않아서 괜찮았다! 주말간 할일... 기술면접 답변 마무리/ git 공부/ 고차함수 못 다 푼 문제 풀기/ class 문제 찾아서 풀기

profile
[무엥일기] 무엥,,, 내가 머쨍이 개발자가 될 수 이쓰까,,,

0개의 댓글