主题:the Segment class
Design a class named Point to represent a point in the plane, and a class named Segment to represent a segment.
Using the class interface as follows:
class Point
{
public:
Point(double x, double y);
void setX(double x);
void setY(double y);
double getX();
double getY();
private:
double x;
double y;
};
class Segment
{
public:
Segment(double beginX,double beginY,double endX,double endY);
double length(); //return the length of the segment
private:
Point beginPoint;
Point endPoint;
};
帮我编出来吧。谢谢
Using the class interface as follows:
class Point
{
public:
Point(double x, double y);
void setX(double x);
void setY(double y);
double getX();
double getY();
private:
double x;
double y;
};
class Segment
{
public:
Segment(double beginX,double beginY,double endX,double endY);
double length(); //return the length of the segment
private:
Point beginPoint;
Point endPoint;
};
帮我编出来吧。谢谢