Question: Add the following method to your Rectangle class: public Rectangle intersection(Rectangle rect) Returns a new Rectangle that represents the largest rectangular region completely contained within

Add the following method to your Rectangle class:

public Rectangle intersection(Rectangle rect)

Returns a new Rectangle that represents the largest rectangular region completely contained within both this Rectangle and the given other Rectangle. If the Rectangles do not intersect at all, returns a Rectangle with width and height both equal to 0.

Step by Step Solution

3.30 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Returns a new rectangle that represents the largest re... 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 Building Java Programs A Back to Basics Approach Questions!