Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

Step: 3

blur-text-image

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

Deductive And Object Oriented Databases Second International Conference Dood 91 Munich Germany December 18 1991 Proceedings Lncs 566

Authors: Claude Delobel ,Michael Kifer ,Yoshifumi Masunaga

1st Edition

3540550151, 978-3540550150

More Books

Students also viewed these Databases questions

Question

2. How is it that some organizations succeed during a recession?

Answered: 1 week ago