Created
March 26, 2020 01:56
-
-
Save hw0k/312923eee42fbc6d9989d9d9fdad22b4 to your computer and use it in GitHub Desktop.
LID 5
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
class Rectangle { | |
protected _width: number = -1; | |
protected _height: number = -1; | |
public get width() { | |
return this._width; | |
} | |
public set width(w: number) { | |
this._width = w; | |
} | |
public get height() { | |
return this._height; | |
} | |
public set height(h: number) { | |
this._height = h; | |
} | |
public get area() { | |
return this._width * this._height; | |
} | |
} | |
class Square extends Rectangle { | |
public set width(w: number) { | |
this._width = w; | |
this._height = w; | |
} | |
public set height(h: number) { | |
this._width = h; | |
this._height = h; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment