Created
March 26, 2020 02:05
-
-
Save hw0k/d69c20fef0ff6f4ac7bb109fe90ef399 to your computer and use it in GitHub Desktop.
LID 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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