You are to design a class Line that implements a line, which isrepresented by theformula y = ax+b. Your class should store a and bas double member variables andwrite a member function intersect()such that L.intersect(K) returns the x coordinate ofthe uniquepoint at which lines L and K intersect. If there is not a uniquesuch point,the function should throw an appropriateexception.
Your function should throw an exception if the two lines are thesame and hence havean infinite number of common points; or areparallel and hence have no point ofintersection. For this, you willneed subclasses EqualLines and ParallelLiines of theclassRunTimeException. The message part of theexceptions should be “Thelines are equal: infinite intersection” for EqualLines and”Thelines are parallel: no intersection” for ParallelLiines. Wheneither exception iscaught, the messages will be printed. This willoccur in the program that uses the Lineclass. The class methodsshould not produce any output.
must be done with out editing the line.h file usinginheritance for the equalsLines and parallelLines, and complete theline.cpp and a test main file to be done in c++

line.h

using namespace std;

class RuntimeException { // generic run-time exception
private:
string errorMsg;
public:
RuntimeException(const string& err) { errorMsg = err; }
string getMessage() const { return errorMsg; }
};

// All that is needed for the special exceptions is theinherited constructor and method.

class EqualLines: public RuntimeException
{
public:

};

class ParallelLines: public RuntimeException
{
public:

};

class Line {
public:
Line(double slope, double y_intercept): a(slope), b(y_intercept){};
double intersect(const Line L) const throw(ParallelLines,
EqualLines);
double getSlope() const {return a;};
double getIntercept() const {return b;};

private:
double a;
double b;
};

line.cpp

#include <iostream>

#include “line.h”

double Line::intersect(const Line L) const throw(ParallelLines,EqualLines)

{

}