1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
package lab6; class Rectangle extends Polygon { public Rectangle(int l, int w) { super(4, l, w, l, w); } public int area() { return this.side(0)*this.side(1); } } class Square extends Polygon { public Square(int l) { super(4, l, l, l, l); } public int area() { return this.side(0)*this.side(1); } }