Create a class called Line with the followings: 1. Private members: p1 and p2 as pointer to Point objects (code provided below), slope and length as double variables 2. Define setter and getter...


Create a class called Line with the followings:
1. Private members: p1 and p2 as pointer to Point objects (code provided below), slope and length as double variables
2. Define setter and getter functions.
3. Define a default constructor that allocate dynamic memory for points and
set everything to 0.
4. Overload a constructor that allocates memory for points, initilize them
with given arguments, and calculate the slope and length.
5. Overload a destructor, a copy constructor and a copy assignment operator.
6. Create a function called ”parallel” that return true when given lines are
parallel and returns false otherwise
7. Overload the less than (<) and="" greater="" than="" (="">) and equality (==) oper-
ators (compare the length)
8. Write a functions that reads lines in the format provided in the lines.txt
from the file and stores them in a vector named Lines.
9. Sort the objects of Lines vector in descending order.
10. Extend the functionality of cin and cout for this class
11. Write a separate file to extensively test your code as you learned in unit
testing lessens.


#include
using namespace std;


#ifndef POINT_H
#define POINT_H


class point {
public:
point(double X = 0, double Y = 0) : x(X), y(Y) {}
void setX(double x) {this->x = x ;}
double getX() const {return this->x ;}
void setY(double y) {this->y = y ;}
double getY() const {return this->y ;}
void print() const;
friend point operator+(point lhp, point rhp);
friend point operator+(point lhp, pair rhp);
friend point operator+(pair lhp, point rhp);
private:
double x;
double y;
};


void point::print() const{
cout < "x,y="" :="" ("="">< this-="">x < ","="">< this-="">y < ")"=""><>
}
point operator+(point lhp, point rhp) {
return point(lhp.x +rhp.x, rhp.y +rhp.y);
}
point operator+(point lhp, pair rhp) {
return point(lhp.x + rhp.first, lhp.y +rhp.second);
}
point operator+(pair lhp, point rhp) {
return point(lhp.first+rhp.x , lhp.second +rhp.y);
}




#endif


lines.txt


lines:
{
[line1:[102.0,0.9],[97.0,1.0]],
[line2:[103.0,0.8],[98.0,1.0]],
[line3:[104.0,0.7],[99.0,1.0]],
[line4:[105.0,0.6],[100.0,1.0]]
}

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here