Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A line can be defined by two points, p 1 : ( x 1 , y 1 ) and p 2 : ( x 2

A line can be defined by two points, p1: (x1, y1)image text in transcribed and p2: (x2, y2)image text in transcribed . The slope of the line can be determined by (y2-y1)(x2-x1) image text in transcribed , given that x2-x1 0image text in transcribed . If y2-y1=0image text in transcribed , then it is a horizontal line, and if x2-x1image text in transcribed , then it is a vertical line. The slope of a vertical line is undefined. Two lines are parallel if they have the same slope or both are vertical lines. Two lines are perpendicular if one of the lines is horizontal and another is vertical, or if the product of their slopes is 1. Design the class lineType to store a line. To store a line, you need to store two Point objects. Your class must contain the following operations:

  1. If a line is nonvertical, then determine its slope.
  2. Determine if two lines are equal.
  3. Determine if two lines are parallel.
  4. Determine if two lines are perpendicular.

Add appropriate constructors to initialize variables of lineType. Also write

a program to test your class.

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago