Answered step by step
Verified Expert Solution
Question
1 Approved Answer
java MyRectangle # width : double # height : double #x : double // center of the rectangle is at (this.x, this.y) # y :
java
MyRectangle # width : double # height : double #x : double // center of the rectangle is at (this.x, this.y) # y : double + MyRectangle() + MyRectangel(double x, double y, double width, double height) +get, set methods for width and height get methods for x and y getArea() : double //returns the area of the rectangle getPerimeter() : double //returns the perimeter of the rectangle getDiagonal() : double // returns the length of the diagonal of the rectangle isSquare(): boolean //returns true if the rectangle is a square, Fig. 1 (e) moveTo(double xO, double yo) void//move the center of the rectangle to (x0, yo) ontains(double xO, double yo): boolean//returns true if (xO, yO) is inside the rectangle as in Fig 1 ontains(MyRectangle r): boolean //returns true, if rectangle r is contained in the rectangle Fig. 1 verlaps(MyRectangle r): boolean //returns true, if rectangle r is contained in the rectangle Fig. 1 isjoint(MyRectangle r): boolean //returns true, if rectangle r is disjoint with the rectangle Fig. 1 uals(MyRectangle r): boolean //returns true if r has the same dimension with the rectangle .1 (a) A point is inside the rectangle. (b) A rectangle is inside another rectangle. (c) A rectang erlaps another rectangle. (d) Two rectangles are disjoint. (e) A rectangle is a square. Implement MyRectangle class as described in the UML. Test it in main method: 1) Create a rectangle named rectA, with center (50, 50), width 80, and height 60. 2) Create a rectangle named rectB, with center (60, 50), width 10, and height 10. 3) Create rectangle named rectC, with center (120, 50), width 20, and height 10 4) Test if (25, 75) is contained by rectA. Display the result. 5) Test if rectB is contained in rectA. Display the result. 6) Test if rectA is a square. Display the result. 7) Display perimeter of rectA. Display the result. 8) Test if rectA and rectC are disjoint. Display the result 9) Move rectA to (85, 50) mit zipned oroiect, result txt (or errors txt if it does not comnile) to D2 AssignmentStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started