In a similar way, the class Rectangle can also be built from the class Shape:
0622: public class Rectangle extends Shape { // Rectangle.java
0623: public Rectangle(int vWidth, int vHeight, int vX, int vY) {
0624: super(vX, vY); iWidth = vWidth; iHeight = vHeight;
0625: }
0626: public Rectangle() { this(0, 0, 0, 0); }
0627: public int getWidth() { return iWidth; }
0628: public int getHeight() { return iHeight; }
0629: public boolean equals(Object rObject) {
0630: return super.equals(rObject)
0631: && iWidth == ((Rectangle) rObject).iWidth
0632: && iHeight == ((Rectangle) rObject).iHeight;
0633: }
0634: public String toString() { return super.toString()
0635: + ":" + iWidth + ":" + iHeight; }
0636: private int iWidth;
0637: private int iHeight;
0638: }