Commit 65ec711c authored by Hans Buchmann's avatar Hans Buchmann

getter x() and y()

parent 62d60730
......@@ -74,9 +74,10 @@ class Point
double distance(const Point& other) const;
//| |--- my own variables cannot be changed
//other cannot be changed
static double distance(Point p,Point q);
// private: Suende
//getter
double x() const;
double y() const;
private:
void svg(); //draw the point
double xc; //x-coordinate
double yc; //y-coordinate
......@@ -123,11 +124,6 @@ void Point::svg()
SVG::dot(xc,yc); //with default radius
}
double Point::distance(Point p,Point q) //is not a member of Point
{
return std::hypot(q.xc-p.xc,q.yc-p.yc);
// |private
}
double Point::distance(const Point& other) const //is a member of Point
// |----------c++ reference
......@@ -144,6 +140,9 @@ double Point::distance(const Point& other) const //is a member of Point
yc- other.yc);
}
inline double Point::x()const{return xc;}
inline double Point::y()const{return yc;}
//----------------------------------------------- Line
// implementation
Line::Line(const Point& p,const Point& q)
......@@ -159,8 +158,8 @@ Line::~Line()
void Line::svg()
{
SVG::line(pp.xc,pp.yc, //x0,y0
qq.xc,qq.yc); //x1 y1
SVG::line(pp.x(),pp.y(), //x0,y0
qq.x(),qq.y()); //x1 y1
}
int main(int argc,char**args)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment