721
edits
Line 10: | Line 10: | ||
To get the x- and y-coordinates in our code, we can use the private variables for point p1 (_x and _y) and the member functions getX() and getY() for point p2. So the most crucial lines of code are: | To get the x- and y-coordinates in our code, we can use the private variables for point p1 (_x and _y) and the member functions getX() and getY() for point p2. So the most crucial lines of code are: | ||
<source lang="c++" line start="1" highlight="4">float Point2D::calculateDistanceToOtherPoint(Point2D p2){ | |||
float Point2D::calculateDistanceToOtherPoint(Point2D p2){ | |||
float distance = sqrt( (p2.getX() -_x)*( p2.getX() -_x)+( p2.getY()-_y)*( p2.getY() -_y) ); | float distance = sqrt( (p2.getX() -_x)*( p2.getX() -_x)+( p2.getY()-_y)*( p2.getY() -_y) ); | ||
return distance; | return distance; | ||
} | }</source> | ||
==File Structuring== | ==File Structuring== |