Answered step by step
Verified Expert Solution
Question
1 Approved Answer
opject-orhete rrogrammi ng Exercises 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
opject-orhete rrogrammi ng Exercises 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; // center of rectangle private final double width; // width of rectangle private final double height; // height of rectangle public RectangleCdouble x0, double yo, double w, double h) x=x0; representation y y0; width w; (x,y) height height h; public double areaO t return width * height; width intersects public double perimeterO Compute perimeter. */ public boolean intersects (Rectangle b) f Does this rectangle intersect b? public boolean contains (Rectangle b) atn Is b inside this rectangle? ) public void draw(Rectangle b) Draw rectangle on standard drawing.*/ Write an API for this class, and fill in the code for perimeterO, intersectso and contains O. Note: Consider two rectangles to intersect if they share one or more common points (improper intersections). For example, a.intersects(a and a.contains (a) are both true
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started