Question: e2 Define the Rcctanglc2D class that contains: Double data fields named xpos, ypos (that specify the top left corner of the rectangle), width and height
Define the Rcctanglc2D class that contains: Double data fields named xpos, ypos (that specify the top left corner of the rectangle), width and height (assume that the rectangle sides arc parallel to the x and y axes. Sec example below). A no-arg constructor that creates a default rectangle with (0.0, 0.0) for (xpos, ypos0 and 1.0 for both width and height. A constructor that creates a rectangle with the specified xpos, ypos, width, and height. Get and set methods for all the instance variables. A method getArea() that returns the area of the rectangle. A method getPerimeter() that returns the perimeter of the rectangle. A method contains(x, y) that returns true if the specified point (x, y) is inside this rectangle. Sec Figure 1(a). A method contains(Point p) that returns true if the specified Point (see Exercise 1) has coordinates inside the rectangle. (This is also similar to Figure 1(a).) A method contains (Point p) that returns true if the specifie4d Point (see Exercise 1) has coordinates inside the rectangle. (This is also similar to Figure 1(A). A method contains(Rectangle2D r) that returns true if the specified Point (See Exercise 1) has coordinates inside the rectangle. (This is also similar to Figure 1(a)). A method contains(Rectangle 2D r) that returns true if the specified rectangle is inside this rectangle. See Figure 1(b). Note that the condition for contains is that all four corners of the second rectangle must be contained in the first. This means, that if the two rectangles are exactly identical, we still say that the second rectangle is contained within the other
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
