Design a class Line that implements a line, which is represented by the formula y = ax+b. Your class should store a and b as double member variables. Write a member function intersect(ℓ) that returns the x coordinate at which this line intersects line ℓ. If the two lines are parallel, then your function should throw an exception Parallel. Write

Chapter 2, Creativity #4

This problem has been solved!


Do you need an answer to a question different from the above? Ask your question!

Design a class Line that implements a line, which is represented by the formula y = ax+b. Your class should store a and b as double member variables. Write a member function intersect(ℓ) that returns the x coordinate at which this line intersects line ℓ. If the two lines are parallel, then your function should throw an exception Parallel. Write a C++ program that creates a number of Line objects and tests each pair for intersection. Your program should print an appropriate error message for parallel lines.

Related Book For answer-question

Data Structures And Algorithms In C++

2nd Edition

Authors: Michael T. Goodrich, Roberto Tamassia, David M. Mount

ISBN: 9780470383278