Answered step by step
Verified Expert Solution
Question
1 Approved Answer
this is a data structurs class. please answer question in c++ language. please answer the question following the coment lines, each comment line has what
this is a data structurs class. please answer question in c++ language. please answer the question following the coment lines, each comment line has what it requirments. program should be written in c++.
i dont understand the question
please just go ahead and solve the question. i still have a weak to review and submit it
Description: A line segment on a two-dimensional space has a defined length and is represented by two points. A point is given by two values (real numbers) x and y. In this project you are going to create three classes and methods for each class. You will then have a main program that will read in information on each line segment (x1, yl, x2, y2) and store the line segments (in an array that will be part of a class described below). We will then answer certain queries on these line segments that are stored (by invoking appropriate methods). Now let us begin by describing the classes you must have along with methods. Please note that you may have additional methods as you deem fit. In the code segments below, there may be syntax errors. It is your responsibility to fix, in case you need to. Also, keep watching for any updates on this project posted on canvas. Round all numbers to two decimal places. Point Class (More information on this is available on your textbook): Your Point class will have the following structure. class Point ( protected: double x; //x coordinate value double y; //y coordinate value public: Point (); //default constructor; x = 0.0 and y = 0.0 Point (double xvalue, double yvalue); /o-default constructor setLocation (double xvalue, double yvalue); // set x xvalue and // y yvalue double getxvalue (); //return x double getYvalue (); //return y void display (); // Print (0.0, 0.0) //other methods that are necessary LineSegment Class: A line segment consists of two Point objects and it has the following structure. class LineSegment { protected: Point Pl; Point P2; public: LineSegment ); //default constructor LineSegment (Point one, Point two); double length(); //return the length of the line segment Point midpoint (); //return the midpoint of the line segment Point xIntercept (); //return the x-intercept of the line segment Point yIntercept (); //return the y-intercept of the line segment double slope (); //return the slope of the line segment bool itIntersects (LineSegment L); //returns true if L intersects //with this line segment Point intersectionPoint (LineSegment L); bool isParallel (LineSegment L); //check if slopes are same void displayEquation () ; // you will print in the format // y = m * x +c where m is the slope //and' c is the y-intercept //other methods that are necessary Intervals Class: This class stores a set of line segments and has its own methods. class Intervals { protected: LineSegment* segments; int count; int maxSize; public: 0; maxSize = 0; Intervals (0; //segments Intervals (int size); /on-default constructor void addLineSegment (Linesegment L); void display (); - NULL; count = /* display all line segment stored in the y-mx+c format; see display for LineSegment, and print points, length, midpoint, k-intercept, y-intercept, for example: Line Segment: 1 P1 = (3.0, 9.0); P2 = (8.0, 16.0) slope = 1.4 equation length mid point x-intercept y-intercept y = 1.4*x + 4.8 8.60 (10.5, 12.5) %3D Line Segment: 2 (...); P2 (...) slope equation length mid point x-intercept y-intercept %3! ... %3D ... ... !3! ... //some extra help below: in case you need it Intervals::Intervals () { NULL; segments count 0; maxSize = 0; Intervals:: Intervals (int size) { = new LineSegment [size]; 0; //currently there is none size; segments count maxSize = Your main program will have the following structure (changes may be required). tinclude Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started