Question: import rectangel import random Exercise 2: The Intersection method computes the intersection of two rectangles-that is, the rectangle that would be formed by two overlapping
Exercise 2: 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 = rl.intersection(r2); Write a program Intersection Printer that constructs two rectangle objects, prints them as described in Exercise 1, and then prints the rectangle object Intersection 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. The random class implements a random number generator, which produces sequences of numbers that appear to be random. To generate random integers, you construct an object of the Random class, and then apply the nextInt (50) gives you a random number between 0 and 49. Use the Random class to construct the two rectangle objects
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
