Question: Develop an implementation of your Rectang 7e API from EXERCISE 3.2.1 that represents rectangles with the (x) - and (y)-coordinates of their lower-left and upperright
Develop an implementation of your Rectang 7e API from EXERCISE 3.2.1 that represents rectangles with the \(x\) - and \(y\)-coordinates of their lower-left and upperright corners. Do not change the API.
Data From in Exercise 3.2.1
Consider the following data-type implementation for axis-aligned rectangles, which represents each rectangle with the coordinates of its center point and its width and height:

public class Rectangle { } private final double x, y; private final double width; private final double height; // center of rectangle // width of rectangle // height of rectangle public Rectangle (double x0, double y0, double w, double h) { X = x0; y = yo; width = w; height = h; } public double area() { return width * height; } public double perimeter() { /* Compute perimeter. */ } public boolean intersects (Rectangle b) { /* Does this rectangle intersect b? */ } public boolean contains (Rectangle b) { /* Is b inside this rectangle? */ } public void draw(Rectangle b) { /* Draw rectangle on standard drawing. */ } representation height intersects contains (x, y) width a
Step by Step Solution
3.43 Rating (150 Votes )
There are 3 Steps involved in it
Solutions Step 1 Determine if the point is inside or outside the rectangle Explanation To determine ... View full answer
Get step-by-step solutions from verified subject matter experts
