As part of a program that will be doing computations on various geometric object
ID: 3597244 • Letter: A
Question
As part of a program that will be doing computations on various geometric objects, a programmer has submitted the following class declaration for approval.
struct Line {
// Provide access to the endpoints
Point p1;
Point p2;
// Create a line segment
Line() {}
// Create a line segment with the given endpoints
Line (Point endPoint1, Point endPoint2);
// For a given x value, what is the corresponding value of
// y along this line segment? (Returns std::DBL_MAX if no
// such y exists or if y is not unique.)
double y(double x) const;
// For a given y value, what is the corresponding value of
// x along this line segment? (Returns std::DBL_MAX if no
// such x exists or if x is not unique.)
double x(double y) const;
// Returns true if these line segments intersect at a point that lies
// at or between the endpoint of each segment.
bool crossesSegment (const Line& segment) const;
// Returns true if p lies along this line segment (and at or
// between the endpoints).
bool contains (Point p) const;
};
ostream& operator<< (ostream& out, Line& line);
Based upon this information, which of the C++ checklist items appear to be in violation? (Choose all that apply)
Redundant or generalizable functions
Meaningful names
Undocumented pre-conditions
All data members private
Every constructor initializes every data member
Appropriate treatment of default constructor
Appropriate treatment of the Big 3
Appropriate relational operators
Appropriate output function
Const correctness
Explanation / Answer
C++ checklist items appear to be in violation:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.