Write Java Program Design Class Mentioned Picture Please Describe Codes Correct Solutions Q43838692
Write a JAVA program to designthe class mentioned in the picture. Please describe your codes.Correct solutions only please.
Given an array of windows in the plane, we want to count how many overlapping and how many enclosing pairs of windows there are (without double counting). A window is the region of the plane enclosed by a rectangle with sides parallel to the x and y axes. A window can be abstracted as an object with the 4 fields of doubles: (left, right, bottom, top). These fields should satisfy the invariant: left < right and bottom < top. The window is the Cartesian product of the x-interval (left, right) and the y-interval [bottom, top), i.e., the set of points (x,y) in the plane such that left <x<right and bottom <y<top. Consider a pair of windows w, and w,. We say these two windows overlap if they have a common interior point (just touching boundaries is not enough). We say w, encloses w, if no part of w, is outside wo. (Note that the first relationship is symmetric but the second is anti-symmetric.) Design a class called Window with the following fields and methods: (Note: you should not confuse this with the Java API class java.awt.Window.) • Protected fields left, right, bottom, top. • A constructor that throws an exception named InvalidWindowException if the given 4 fields do not satisfy the above invariant. Public getters and setters for these fields. The setters also throw Invalid WindowException if invalid field value is attempted to be set. • Boolean instance method encloses(Window w) returns true if and only if the instance window encloses the argument window w. • Boolean instance method overlaps(Window w) returns true if and only if the instance window overlaps the argument window w. • Static method overlapCount(Window[] windows) returns the number of (unordered) overlapping pairs of windows in the input array windows. Static method enclosureCount(Window[] windows) returns the number of (ordered) enclosing pairs of windows in the input array windows. main() method runs some interesting test cases of the above methods. Show transcribed image text Given an array of windows in the plane, we want to count how many overlapping and how many enclosing pairs of windows there are (without double counting). A window is the region of the plane enclosed by a rectangle with sides parallel to the x and y axes. A window can be abstracted as an object with the 4 fields of doubles: (left, right, bottom, top). These fields should satisfy the invariant: left
Expert Answer
Answer to Write a JAVA program to design the class mentioned in the picture. Please describe your codes. Correct solutions only pl…
OR