import java.awt.Rectangle;
public class AddTester {
public static void main(String[] args) {
Rectangle box = new Rectangle(5, 10, 20, 30);
System.out.println(box);
//output: java.awt.Rectangle[x=5,y=10,width=20,height=30]
box.add(0, 0);
System.out.println(box);
//output: java.awt.Rectangle[x=0,y=0,width=25,height=40]
}
}
Why does the width and the height change after calling the add(int newx, int newy) method on the box object?
I actually just drew the rectangle on a cartesian system on paper. Now it looks that it might be because another rectangle is inserted as an extension of the current rectangle. Hence, it extends in width and height. Is this correct?