Need help with this assignment
Hey guys, I need help with this one question on my assignment. I don't get how to do it. Thanks
I wrote this
import java.awt.Rectangle ;
import java.util.Random ;
Practice using getX, getY, getWidth and getHeight
public class IntersectionTester
public static void main(String args)
Random random = new Random() ;
Rectangle box1 = new Rectangle(2 * random.nextInt(50),
2 * random.nextInt(50),
2 * random.nextInt(100),
2 * random.nextInt(100)) ;
//Reminder: do not write or change code outside of the todo regions.
//----------------------Start here. Do not remove this comment.
// todo: 1. Make a second rectangle, called box2, so that the top left corner of box2 is in the center of box1, the width of box2 is half the width of box1, and the height of box2 is half the height of box1.
// approximate lines of code required: 4
//----------------------End here. Do not remove this comment.
Rectangle box3 = box1.intersection(box2) ;
and I got this error
Rectangle box2 = new Rectangle(box1.getX(),
Can someone please tell me what to do here. Thanks
IntersectionTester.java.23: cannot find symbol
symbol : constructor Rectangle(double,double,double,double)
location : class java.awt.Rectangle
Rectangle box2 = new Rectangle(box1,get(),
Re: Need help with this assignment
Read what the compiler message is trying to tell you: there is no constructor in the Rectangle class that takes four doubles for its parameters (also read the API documentation for the Rectangle class). You can cast the four values to ints '(int)value'.