Question: write C++ program for main.cpp part and complete point.cpp and point.h For this lab we are going to start off with a fairly simple class.
write C++ program
for main.cpp part and complete point.cpp and point.h




For this lab we are going to start off with a fairly simple class. This class is going to contain a point on a plane and will contain a X coordinate and Y coordinate. The class is also going to contain a member function that returns the distance between the Point object and a Point object passed as an argument. Using Theia create a Lab4 project on your system and download the files below into your project. Create a directory named 'src'and copy the .cpp and .h files in the that directory and place the CmakeLists.txt file in the project's top level directory. . The Point.h file declares the class and you will create a Point.cpp that contains your implementation of the constructors and member functions. The default Point constructor (the constructor with no arguments) will set the x,y values to zero. Write the necessary member functions in your Point.cpp file as declared in the Point.h file. Implement main() to test the various class member functions. Note that the test outputs only when an error occurs. Remember to include the floating point compare function files from Comparing Floating-Point Numbers. You do not need these files for your class code but the provided test code does require the functions. Tar the entire Lab4 project and submit. Do not modify the public portion of the Point.h class declaration. At this time there are no requirements to add private member functions and variables. FloatCompare.cpp FloatCompare.h D Point.h CMakeLists.txt D Float Compare.cpp #include "Float Compare.h" /** * The two values are approximately equal @param a left hand value @param b right hand value @param epsilon the difference between 1.0 and the next value representable by the floating-point * @return true is approximately equal bool approximatelyEqual(float a, float b, float epsilon) { return fabs (a - b) fabs(b) ? fabs(b) : fabs(a)) * epsilon); } /** The one value definitely greater than the other @param a left hand value @param b right hand value @param epsilon the difference between 1.0 and the next value representable by the floating-point * @return true is definitely greater than */ bool definitelyGreaterThan(float a, float b, float epsilon) { return (a - b) > ((fabs(a) ((fabs(a) x = x; this->y = y; } /** @brief Destroy the Point:: Point object */ Point::-Point() { //empty } * @brief get X * @return double * double Point::getX() const{ return x; } point.cpp * Created on: feb 21, 2021 ** #ifndef POINT_H_ #define POINT_H_ class Point { public: /** * Constructors and destructor */ Point(); Point(const double x, const double y); virtual ~Point(); /** * Get the x value */ double getx() const; /** * Get the y value */ double getY() const; * Return the distance between Points */ double distance(const Point &p) const; private: double x; double y; }; #endif /* POINT_H_ */
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
