Skip to content

Instantly share code, notes, and snippets.

@md2perpe
Created June 23, 2015 19:36
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 md2perpe/ea3b5e8ac3f2d36aa748 to your computer and use it in GitHub Desktop.
Save md2perpe/ea3b5e8ac3f2d36aa748 to your computer and use it in GitHub Desktop.
Square as a subclass of Rectangle
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