Skip to content

Instantly share code, notes, and snippets.

@hw0k
Created March 25, 2020 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hw0k/1ca0cdff6124af5e021647dd8117118e to your computer and use it in GitHub Desktop.
Save hw0k/1ca0cdff6124af5e021647dd8117118e to your computer and use it in GitHub Desktop.
LID 3
interface Animal {
eat(): void;
sleep(): void;
cry(): void;
}
interface FlyableAnimal extends Animal {
fly(): void;
}
class Bird implements FlyableAnimal {
eat(): void {
console.log('새가 음식을 먹었어요!');
}
sleep(): void {
console.log('Zzzzzz....');
}
cry(): void {
console.log('짹짹!!');
}
fly(): void {
console.log('새가 하늘을 날았어요!');
}
}
class Human implements Animal {
eat(): void {
console.log('아 배부르다');
}
sleep(): void {
console.log('Zzzzzz....');
}
cry(): void {
console.log('ㅠㅠㅠ');
}
// fly() 메서드를 구현하지 않는다. ISP 준수!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment