Question: Write a program to test the classes pointType and lineType defined in Exercise 30 of this chapter. Add a member function to the class lineType
Write a program to test the classes pointType and lineType defined in Exercise 30 of this chapter. Add a member function to the class lineType to find the point of intersection of two lines if they are not parallel.
Below are the lineType.h and pointType.h
also I added main.cpp which is blank.
I need lineTypeImp.cpp and pointTypeImp.cpp
*lineType.h*
#ifndef lineType_H
#define lineType_H
#include "pointType.h"
class lineType
{
public:
void setLineCoordinates(double a1 = 0, double b1 = 0,
double a2 = 0, double b2 = 0);
void setLineCoordinates(pointType& p1,
pointType& p2);
void getLineCoordinates(pointType& p1, pointType& p2);
double slope();
// If line is vertical, then the function
// returns -999999999999999.
void lineEquation();
bool isVerticalLine();
bool isHorizontalLine();
bool parallel(lineType& l);
pointType intersectionPoint(lineType& l);
lineType(double a1 = 0, double b1 = 0,
double a2 = 0, double b2 = 0);
lineType(pointType& p1, pointType& p2);
private:
pointType a;
pointType b;
};
#endif
main.cpp
#include
using namespace std;
int main() {
// Write your main here
return 0;
}
pointType.h
#ifndef pointType_H
#define pointType_H
class pointType
{
public:
void setPoint(double a = 0, double b = 0);
//Function to set the x and y coordinates of a point
//Postcondition x = a; y = b;
void setX(double a = 0);
//Function to set x coordinate.
//Postcondition: x = a;
double getX();
//Function to return the x coordinate.
void setY(double b = 0);
//Function to set y coordinate.
//Postcondition: y = b;
double getY();
//Function to return the y coordinate.
double distance(pointType & point);
//Function to return the distance between this point
//point
void print() const;
//Function to print the x and y coordinates.
pointType(double a = 0.0, double b = 0.0);
//Constructor with a default parameter.
private:
double x;
double y;
};
#endif
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
