define the myrectangle2d class that contains: ■ two double data
define the myrectangle2d class that contains:■ two double data fields named x and y that specify the center of the rectangle with get and set methods. (assume that the rectangle sides are parallel to x- or y- axes.)■ the data fields width and height with get and set methods.■ a no-arg constructor that creates a default rectangle with (0, 0) for (x, y) and 1 for both width d 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.15(a).■ a method contains(myrectangle2d r) that returns true if the specified rectangle is inside this rectangle. see figure 10.15(b).■ a method overlaps(myrectangle2d r) that returns true if the specified rectangle overlaps with this rectangle. see figure 10.15(c).draw the uml diagram for the class. implement the class. write a test program that creates a myrectangle2d object r1 (new myrectangle2d(2, 2, 5.5, 4.9)), displays its area and perimeter, and displays the result of r1.contains(3, 3), r1.contains(new myrectangle2d(4, 5, 10.5, 3.2)), and r1.overlaps(new myrectangle2d(3, 5, 2.3, 5.4)).
Price Type: Negotiable
Total Proposals: 5
1 Current viewersl
52 Total views