/**** * * A simple Java program that defines a rectangle data structure and two methods * that operate on rectangles. * */ public class Rectangle { int x; int y; int width; int height; Rectangle(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; } void move(int x_increment, int y_increment) { x = x + x_increment; y = y + y_increment; } boolean equals(Rectangle r) { return x == r.x && y == r.y && width == r.width && height == r.height; } public static void main(String[] args) { Rectangle r1 = new Rectangle(10, 20, 100, 200); Rectangle r2 = new Rectangle(20, 30, 100, 200); boolean eq; eq = r1.equals(r2); if (eq == false) { System.out.println("r1 not = r2"); } else { System.out.println("r1 = r2"); } r1.move(10, 10); eq = r1.equals(r2); if (eq == false) { System.out.println("r1 not = r2"); } else { System.out.println("r1 = r2"); } } }