Skip to content

Instantly share code, notes, and snippets.

@hw0k
Created March 26, 2020 02:05
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/d69c20fef0ff6f4ac7bb109fe90ef399 to your computer and use it in GitHub Desktop.
Save hw0k/d69c20fef0ff6f4ac7bb109fe90ef399 to your computer and use it in GitHub Desktop.
LID 7
// Shape 인터페이스는 넓이를 구할 수 있는 것(기하학 관점의 면)이라고 가정한다.
interface Shape {
readonly area: number;
}
class Rectangle implements Shape {
constructor(public width: number, public height: number) {}
public get area() {
return this.width * this.height;
}
}
class Square implements Shape {
constructor(public width: number) {}
public get area() {
return this.width ** 2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment