How to check if two rectangles intersect or not ?
-
- The following standard Java coding practices to solve this problem.
- We have an encapsulated two co-ordinates in a Point class and have Rectangle has two Point instance variable and an instance method like equals() to check if another rectangle is overlapping or not.
- A rectangle can be represented by two coordinates, top left, and bottom right. As part of the problem you will be given four coordinates L1, R1 and L2, R2, top left and bottom right coordinate of two rectangles and you need to write a function isOverlapping() which should return true if rectangles are overlapping or false if they are not.