Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students explore these related Databases questions