Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribedthis is data structures. please give me an explanation after each step. also the code has some errosrs as stated below.
image text in transcribed
the program language to be used is c++
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 using namespace std; //define all your classes here (as given above) //write the methods after the class definition (not inside the class 7/definition, see above in the Intervals class int main() { //make sure you define all the variables; I have defined ANY //first line of input contains the number of segments cin >> noofsegments; //Go through a loop (noofsegments times) and read the information about 11 ach segment it will be as follows: // 2.3 3.5 2.5 8.12 // 5.13 8.13 9.0 42.8 //After you read information on each segment you need to create two 7/Point objects, with these point objects you will next create a //LineSegment object and then this Line Segment object is placed in the 1/object you create for Intervals class using the addLineSegment method //Next .. //Call the display method on the Intervals Object you created //Next ... // /* Determine ALL PAIRS of intersecting Line Segments and print just their position in which they are stored in the array. For example, (0, 8) (0, 14) (0, 32) (1, 11) You must ensure that your program outputs the correct results. Redirected Input: Redirected input provides you a way to send a file to the standard input of a program without typing it using the keyboard. To use redirected input in Visual Studio environment, follow these steps: After you have opened or created a new project, on the menu go to project, project properties, expand configuration properties until you see Debugging, on the right you will see a set of options, and in the command arguments type using namespace std; int main() { int r,c,cv,nsv; int val; cin >> r >> C >> cv >> nsv; for (int i=0; i > value; cout and using namespace std. 2. None of the projects is a group project. Consulting with other members of this class our seeking coding solutions from other sources including the web on programming projects is strictly not allowed and plagiarism charges will be imposed on students who do not follow this. 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

What are the role of supervisors ?

Answered: 1 week ago