Write a program called FourRectanglePrinter that constructs a Rectangle object, prints its location by calling System.out.println(box), and then translates and prints it three more times, so that, if the rectangles were drawn, they would form one large rectangle, as shown at right. Your program will not produce a drawing. It will simply print the locations of the four rectangles.

Respuesta :

The program called FourRectanglePrinter constructs a Rectangle object, prints its location by calling System.out.println(box), and then translates and prints it three more times, so that, if the rectangles were drawn, they would form one large rectangle. This will print the location of the four rectangles.

Explanation:

import java.awt.Rectangle;

public class FourRectanglePrinter

{

public static void main(String[] args)

{

System.out.println(" ");

Rectangle box = new Rectangle(10, 20, 30, 40);

System.out.println(box);

System.out.println(" ");

box.translate(0,30);

System.out.println(box);

box.translate(40,0);

System.out.println(box);

box.translate(40,30);

System.out.println(box);

}

}

The above code is done in java.

ACCESS MORE
EDU ACCESS
Universidad de Mexico