Created
June 23, 2015 19:36
-
-
Save md2perpe/ea3b5e8ac3f2d36aa748 to your computer and use it in GitHub Desktop.
Square as a subclass of Rectangle
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 double width, height; | |
constructor(double width, double height) | |
{ | |
this.width = width; | |
this.height = height; | |
} | |
public getWidth() { return this.width; } | |
public getHeight() { return this.height; } | |
} | |
class Square extends Rectangle | |
{ | |
constructor(double side) | |
{ | |
parent.constructor(side, side); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment