Given the class declaration class Point{ public: Point (int=0, int=0); // initia
ID: 3641025 • Letter: G
Question
Given the class declaration class Point{ public: Point (int=0, int=0); // initializes xCoord and yCoord void setPoint (int, int); // assigns values to xCoord and yCoord int getX( ) const; // returns value in xCoord int getY( ) const; // returns value in yCoord private: int xCoord; //X coordinate of the point int yCoord; //Y coordinate of the point }; Define the header for a class called Line. Class Line will have member data startPoint and endPoint, both of class Point, as well as the following member functions. Line - constructor that accepts 4 integers in its parameter list representing two sets of X/Y coordinates startingPoint -- returns the point object marking the beginning of the line. endingPoint - returns the point object marking the end of the line.Explanation / Answer
I hope this works for ya! I believe it is what you were asking for... #include "Point.h" //You will have to include this header file for this class to work properly class Line { private: Point startPoint(); //Starting point, initialized with 0,0 Point endPoint(); //Ending point, initialized with 0,0 public: //This is the constructor that accepts 2 sets of X/Y coordinates Line(int x1, int y1, int x2, int y2) { startPoint.setPoint(x1, y1); endPoint.setPoint(x2,y2); } //This function will return the starting point Point startingPoint() { return startPoint; } //This function will return the ending point Point endingPoint() { return endPoint; } };
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.