Skip to content

Instantly share code, notes, and snippets.

@hw0k
Created March 26, 2020 01:56
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/312923eee42fbc6d9989d9d9fdad22b4 to your computer and use it in GitHub Desktop.
Save hw0k/312923eee42fbc6d9989d9d9fdad22b4 to your computer and use it in GitHub Desktop.
LID 5
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