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 : double

Java image 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 I/ returns the length of the diagonal of the rectangle isSquare): boolean //returns true if the rectangle is a square, Fig. 1 (e) moveTo(double x0, double yo): void//move the center of the rectangle to (x0, yo) ontains(double x0, double yo): boolean //returns true if (x0, y0) 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 proiect. result txt (or errors tyt if it does not comnilel to D21 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

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions

Question

What must a creditor do to become a secured party?

Answered: 1 week ago

Question

When should the last word in a title be capitalized?

Answered: 1 week ago