Question: Using the following in Java- package intersectionprinter; import java.awt.Rectangle; public class IntersectionPrinter { public static void main(String[] args) { Rectangle r1 = new Rectangle(0,0,100,150); System.out.println(r1);
Using the following in Java-
package intersectionprinter; import java.awt.Rectangle;
public class IntersectionPrinter {
public static void main(String[] args) { Rectangle r1 = new Rectangle(0,0,100,150); System.out.println(r1); Rectangle r2 = new Rectangle(50,75,100,150); System.out.println(r2); Rectangle r3 = r1.intersection(r2); }
}
Write a program that takes both Rectangle objects, and uses the intersection method to determine if they overlap. If they do overlap, then print it's coordinates along with its width and height. If there is no intersection, then have the program print that there is no overlap.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
