(Geometry: the MyRectangle 2D class) Define the MyRectangle2D class that contains:
- Two double data fields named x and y that specify the center of the rectangle with getter and setter methods. (Assume the rectangle sides are parallel to x - or y-axis.)
- The data fields width and height with getter and setter methods.
- A no-arg constructor that creates a default rectangle with (0, 0) for (x, y) and 1 for both width and height.
- A constructor that creates a rectangle with the specified x, y, width, and height.
- A method getArea () that returns the area of the rectangle.
- A method getPerimeter() that returns the perimeter of the rectangle.
- A method contains(double x, double y) that returns true if the specified point (x, y) is inside this rectangle (see Figure 10.24a).
- A method contains(MyRectangle2D r) that returns true if the specified rectangle is inside this rectangle (see Figure 10.24b).
- A method overlaps (MyRectangle2D r) that returns true if the specified rectangle overlaps with this rectangle (see Figure 10.24c).
FIGURE 10.24 A point is inside the rectangle. (b) A rectangle is inside another rectangle. (c) A rectangle overlaps another rectangle. (d) Points are enclosed inside a rectangle.
Draw the UML diagram for the class then implement the class. Write a test
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
Additional Engineering Textbook Solutions
Problem Solving with C++ (10th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Degarmo's Materials And Processes In Manufacturing
Java: An Introduction to Problem Solving and Programming (8th Edition)
Starting Out with Python (4th Edition)
- can you draw the shortest path tree using BFS for the following directed unweighted graph?arrow_forwardWhat is the shortest path from vertex 3 to all other vertices:Which graph algorithm can solve the problem most efficiently(the quickest runtime)How could the same algorithm if the graph had edge weights? (create intermediate nodes)arrow_forwardThe difference between (1) a database management system (DBMS) and (2) a database, is: a. The first refers to a complete accounting system, the second refers to a subset of that b. The first is program software, the second is proprietary data and related files c. The first is hardware, the second is software d. Nothing—these terms are synonyms..arrow_forward
- a) An example of the linear hash index is given below. Every time a new overflow page is added, the bucket pointed by Next is split, and Next is incremented by one. Show the index state after adding the keys 39, 25, and 29. hi ho Level=0, N=4 000 00 0*8* 001 01 17*33* 010 10 6*26* 42* 011 11 7* 11* 15* 23* 100 00 4* 12* 20* 101 01 5* 13* 21* 37* Nextarrow_forwardWhat would be the runtime (big-O asymptotic notation) of Dijkstra’s algorithm if it is implemented based on an unsorted minimum priority queue in terms of vertices (v) and edges (e)? Please show all steps including the runtime of each step of the algorithm.arrow_forwarda) An extendable hashing index is given below. Present the state of the index after adding the keys 21, 25, and 29. Directory Buckets 0*8* 12* 20* 00 9* 13*33* 01 10 6*26* 42* 11 7* 11* 15*23* b) Explain the concepts of global depth and local depth of buckets. Which buckets in the index above (after inserting 21, 25 and 29) have a global depth equal to the local depth? c) Describe the bulk loading algorithm for B+ trees. What are the differences to using a simple B+ tree add operation?arrow_forward
- b) Below is an example of a B+ tree. Add an element with key 19 and then delete an element with key 1. Present the final result. 1* 3* . 10 18 24 27 37 10*15* - 18 20 22 24*26* 24* 26* - 27* 30*32* 37*40*arrow_forwardBooks (bid, author, title, publisher, year, notes); Members (mid, name, surname, street, city, country, phone, notes); Borrow (rid, bid, mid, date, notes);arrow_forwardCustomer (cid, name, surname, city, address, phone) Account (aid, cid, amount, currency, created) Deposit (did, aid, cid, amount, date) Withdraw(wid, aid, cid, amount, date)arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education