Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Check if a specific point x,y is inside a rectangle...(What I have so far is below) My code (c++): bool Rectangle::constains(Point& p) { double x
Check if a specific point x,y is inside a rectangle...(What I have so far is below)
My code (c++):
bool Rectangle::constains(Point& p) {
double x = p.getX();
double y = p.getX();
// need help here
}
Some background on the program:
. Rectangle(p1: Point, heightValue : double, widthValue : double) Construct rectangle using given point as upper left corner and the indicated width and height . Rectangle(p1: Point, p2 Point) Construct rectangle using given points as upper left (p1) and lower right (p2) corners. Note that you will not store p2. You should just use it and p1 to figure out the width and height of your rectangle. A rectangle made with (1, 2) and (6, -2) as its corners would have a width of 5 and a height of 4. . getUpperLeftVertex() : Point Return Point representing location of the upper left vertex of the rectangle getWidth(): double - returns value getHeight() : double -returns value getArea() : double -calculate and return value getPerimeter() : double - calculate and return value getCenter): Point -calculate location, make a new point representing it to return shift(x: double, y : double) Move the rectangle by the given amount in x and y dimensions. Do so by moving the Point your rectangle is based on contains(p : Point): boolean Return true if indicated Point is within the rectangle (on edge counts as within) ed this functionStep 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