i have to construct a rectangle, print the location, then translate/print it 3 more times such that if they were drawn, they would form one large rectangle.
[][] <- like so
[][]
here's the code & the error.
C:\java>javac FourRectanglePrinter.java
FourRectanglePrinter.java:11: incompatible types
found : void
required: java.awt.Rectangle
Rectangle box1 = box.translate(0,30);
- ^
FourRectanglePrinter.java:14: incompatible types
found : void
required: java.awt.Rectangle
Rectangle box2 = box.translate(40,0);
- ^
FourRectanglePrinter.java:17: incompatible types
found : void
required: java.awt.Rectangle
Rectangle box3 = box.translate(40,30);
- ^
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(" ");
Rectangle box1 = box.translate(0,30);
System.out.println(box1);
System.out.println(" ");
Rectangle box2 = box.translate(40,0);
System.out.println(box2);
System.out.println(" ");
Rectangle box3 = box.translate(40,30);
System.out.println(box3);
}
}