Question: Q1. Write a Line class to represent a line in a 2D plane. The class has two data members defining a line, a slope and

 Q1. Write a Line class to represent a line in a

Q1. Write a Line class to represent a line in a 2D plane. The class has two data members defining a line, a slope and an intercept it must not have any other data members. it should have the following public methods: .A constructor taking a slope and an intercept value to make a new line A constructor that takes a set of point coordinate values x1, y1, x2, y2, which define a line passing through the points (x1,y1) and (x2.y2) .A method double distance To(Point p) which returns the distance between the line and a given point object p .A method Point intersection(Line In) which returns the intersection point of this line and a given line In Use the Point class given below for the Point type needed in the last two methods (put it in your code before your Line class). Do not modify this Point class class Point ( private: double x, ys public: Point(double _x, double _y) x(_x), y(y) ( double_x) return x; double _y return y; double distanceTo(const Point & p) return sqrt((x-p.x)(x-p.x) (y-p.y)"(y-p.y)); 1i Q2. Write a function (not a method of a class), that uses the functionality already provided by your Line class, to solve any pair of simultaneous equations of the form Your function should have the following form Point solve(double al, double b1, double c1, double a2, double b2, double c2) { /* use Line objects here to find the answer -don't rewrite any code unnecessarily } Test your method using the following code in maino Point sol solve (2.5, -2.0, 3.0, 1.5, -3.0, -4.1); cout

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!