1. Engineering
  2. Computer Science
  3. check if a specific point xy is inside a rectanglewhat...

Question: check if a specific point xy is inside a rectanglewhat...

Question details

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 function

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution