public class Rectangle { // fields private int width; private int height; private Point origin; // add an instance variable for the object ID private int id; // add a class variable for the // number of Rectangle objects instantiated private static int numberOfRectangles = 0; // constructors public Rectangle(int initWidth, int initHeight, Point initOrigin) { width = initWidth; height = initHeight; origin = initOrigin; id = ++numberOfRectangles; } public int getID() { return id; } public static int getNumberOfRectangles() { return numberOfRectangles; } // methods public void setWidth(int newWidth ) { width = newWidth; } public int getWidth() { return width; } public void setHeight(int newHeight ) { height = newHeight; } public int getHeight() { return height; } public void setOrigin(Point newOrigin) { origin = newOrigin; } public Point getOrigin() { return origin; } public int getArea() { return width * height; } // Move rectangle origin by dx,dy public void move(int dx, int dy) { origin.setX( origin.getX() + dx ); origin.setY( origin.getY() + dy ); } }