Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. a) Add the prototype of a new member function called quadrant to the Point cl

ID: 3869744 • Letter: 1

Question

1. a) Add the prototype of a new member function called quadrant to the Point class. This method will return the quadrant in which the point is located. Quadrant numbers are shown in Figure I below. Member function quadrant should have a return type different than void. Don't write the definition of the member function quadrant in point.h file b) Add the prototype of a member function midPoint (....) to the class Point which creates an object of class Point as a midpoint of two objects of class Point. (Use only one formal parameter and determine the return type of function midpoint). Don't write the definition of the member function midPoint (....) in point.h file. e) Add the prototypes of two new overloaded member functions distance. One of them determines the distance of point to the origin( 0) and the other one determines the distance from one object of class Point to another object of class Point.( (The first one does not have formal parameters and the second one has only one formal parameter. For both functions distance the return type is double. Don't write the definition of the member functions distance in point.h file. pointh #ifndef POINT 11 #define POINT H class Point t public: default constructor (creates Point at origin) Point) II Create Point using x-y coordinates Point(double xx, double yy): I/ prototype of member function midpoint Fig. I. Quadrants midPoint( ); double getx O; void setXY( double xx, double yy): double gety O I prototype of member function quadrant quadrant. Il prototype of member function distance to another point void printO private double x double y : #endif (For .h file-30 points; for implementation cpp file -30 points)

Explanation / Answer

Here is the code for Point.h:

#ifndef POINT_H
#define POINT_H
class Point
{
    public:
        Point();
        Point(double xx, double yy);
        Point midPoint(Point p);   //Member function midPoint().
        double getX();
        void setXY(double xx, double yy);
        double getY();
        int quadrant();   //Member function quadrant().
        double distance();   //Member function distance().
        double distance(Point p);
        void print();
    private:
        double x;
        double y;  
};
#endif

Point.cpp:

//Non-member functions.
Point midPoint(Point p, Point q);   //Non-member function midpoint.
double distanceR(Point p);   //Non-member function distanceR.
double distanceRR(Point p, Point q);   //Non-member function distanceRR.