Question: The intersection method computes the intersection of two rectanglesthat is, the rectangle that would be formed by two overlapping rectangles if they were drawn, as

The intersection method computes the intersection of two rectangles—that is, the rectangle that would be formed by two overlapping rectangles if they were drawn, as shown at right.

You call this method as follows:

Rectangle r3 = r1.intersection (r2);

Write a program IntersectionPrinter that constructs two rectangle objects, prints them as described in Exercise •• P2.1, and then prints the rectangle object that describes the intersection. Then the program should print the result of the intersection method when the rectangles do not overlap. Add a comment to your program that explains how you can tell whether the resulting rectangle is empty.

image text in transcribed

Rectangle r3 = r1.intersection (r2);

Step by Step Solution

3.40 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Based on your prompt youre asking for a program that creates two rectangles computes their intersection and prints the result The program should also ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming Questions!