Question: this is data structures. please give me an explanation after each step. also the code has some errosrs as stated below. the program language to






this is data structures. please give me an explanation after each step. also the code has some errosrs as stated below.
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, y1, 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. 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 Line Segment { protected: - Point P1; 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 Lintersects //with this line segment Point intersection Point (Line Segment L); T bool isParallel (Line Segment 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: Intervals 0; //segments = NULL;' count = 0; maxSize = 0; Intervals (int size); /on-default constructor void addLineSegment (LineSegment L); void display(); /* display all line segment stored in the y=mx+c format; see display for LineSegment and print points, length, midpoint, x-intercept, y-intercept, for example: Line Segment: 1 P1 = (3.0, 9.0); P2 = (8.0, 16.0) slope - 1.4 equation = y = 1.4*x + 4.8 length = 8.60 mid point = (10.5, 12.5) x-intercept - .. y-intercept = ... Line Segment: 2 P1 - (...); P2 = (...) slope = ... equation = y = ... length = ... mid point - ... x-intercept = ... Y-intercept - ... // some extra help below: in case you need it Intervals::Intervals () { segments = NULL; count = 0; maxSize = 0; Intervals:: Intervals (int size) { segments = new LineSegment (size); count = 0; //currently there is none maxSize = size; Your main program will have the following structure (changes may be required). #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
