Consider the Rectangle class that we developed in class.
It has a constructor with double parameters,
the width and the length of
the rectangle (in that order).
Suppose that the following program:
public class Rect2Test {
public static Rectangle r1, r2, r3, r4, r5;
public static void main(String[] args) {
double x = 2;
double y = 3;
r1 = new Rectangle(x, y);
r2 = new Rectangle(x, y);
r3 = new Rectangle(x + 2, y + 3);
r4 = r2;
r5 = r3;
showRectangleWidths();
x = x + 1;
r1.setWidth(25);
showRectangleWidths();
r2.setWidth(15);
showRectangleWidths();
r2 = new Rectangle(2 * x, 2 * y);
showRectangleWidths();
x = 30;
r5.setWidth(x);
showRectangleWidths();
}
private static void showRectangleWidths() {
System.out.println(r1.getWidth() + " " + r2.getWidth() + " " +
r3.getWidth() + " " + r4.getWidth() + " " +
r5.getWidth());
}
}
Answer the questions: