Question: Code for Point Class: class Point { private: double x, y; public: Point() { this->x = 0; this->y = 0; } Point(double x, double y)

Code for Point Class:

class Point {

private: double x, y;

public: Point() { this->x = 0; this->y = 0; } Point(double x, double y) { this->x = x; this->y = y; }

void set_point(double x0, double y0){ this->x = x0; this->y = y0; }

void set_x(double x0) { this->x = x0; }

void set_y(double y0) { this->y = y0; }

double get_x() { return this->x; }

double get_y() { return this->y; }

friend ostream &operator<<( ostream &output, const Point &P ) { output << "x : " << P.x << " y : " << P.y << endl; return output; }

friend istream &operator>>( istream &input, Point &P ) { cout << "Enter x: "; input >> P.x; cout << "Enter y: "; input >> P.y; return input; }

// helper function used to calculate distance

static double get_distance (Point p1, Point p2){ return sqrt(pow(p2.get_x() - p1.get_x(), 2) + pow(p2.get_y() - p1.get_y(), 2) * 1.0); } };

int main() { Point P1; cout << "Enter P1: "; cin >> P1;

cout << "P1: "; cout << endl; cout << P1; cout << endl; return 0; }

Create an object to implement a line class which allows the programmer to store a line. This class must use the point class that you have pre-developed. The object should have two constructors, appropriate set/get functions, and overloaded I/O (cin/cout) functions. It should include functions the return the proper value for the following:

-Determine the slope of a line-

-Determine the length of a line

-Determine the y-intercept of a line

-Determine if the line is horizontal

-Determine if the line is vertical

-Determine if a line is parallel to another line

-Determine if a line intersects another line

Any help is greatly appreciated.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!