/* Copyright 2001 Michael R. Wick */ package Shapes; import java.awt.*; public class Rectangle extends Polygon { int height, width; protected final static int SIDES = 4; public Rectangle(Point center, int h, int w, Color aColor) { super(center,SIDES,aColor); height = h; width = w; theVertices[0] = new Point(center.x - w/2, center.y - h/2); theVertices[1] = new Point(center.x - w/2, center.y + h/2); theVertices[2] = new Point(center.x + w/2, center.y + h/2); theVertices[3] = new Point(center.x + w/2, center.y - h/2); } public Rectangle( Rectangle orig ){ super(orig); height = orig.height; width = orig.width; theVertices = new Point[SIDES]; for(int i = 0; i < theVertices.length; i++){ theVertices[i] = new Point( orig.theVertices[i] ) ; } } public Shape copy(){ return (new Rectangle(this) ); } }