Help with figuring out program

closed account (yh54izwU)
I don't work with classes to much and was trying to figure this out any help would be great. Thanks

////MARKED LIKE THIS PARTS ARE WHAT I GUESSED////


..............given this...........
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
};




...........answer these............

(a) Define the header for a class called Line.
////#include “Line.h”/////


Class Line will have member data startPoint and endPoint, both of class Point, as well as the following member functions.

////Point.startPoint();////

////Point.endPoint();////


Line -- constructor that accepts 4 integers in its parameter list representing two sets of X/Y coordinates

////Line(int x, int y){

x1=x;
x2=x;
y1=y;
y2=y;
}////


startingPoint -- returns the point object marking the beginning of the line.

////*Point startingPoint(){
Return *Point;
}////

endingPoint -- returns the point object marking the end of the line.
////*Point startingPoint(){
Return *Point;
}////


setStart -- accepts a point object that represents the new starting point of the Line object

//// void setStart(*point){

}////
setEnd -- accepts a point object that represents the new ending point of the Line object.
//// void setStart(*point){

}////


longest -- compares two Line objects and returns the Line object that is longest.
////?????////
length -- returns the length of the line.
////?????/////

(b) Write complete function definitions for Line, longest (assume length has already been coded) , startingPoint and setStart.
////????////
Last edited on
Topic archived. No new replies allowed.