Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java MyRectangle # width : double # height : double #x : double // center of the rectangle is at (this.x, this.y) # y :

javaimage text in transcribed

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 Assignment

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

Explain what is meant by the terms unitarism and pluralism.

Answered: 1 week ago