721
edits
Line 8: | Line 8: | ||
[[File:distance_calc.png|800px]] | [[File:distance_calc.png|800px]] | ||
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: | |||
float Point2D::calculateDistanceToOtherPoint(Point2D p2){ | |||
float distance = sqrt( (p2.getX() -_x)*( p2.getX() -_x)+( p2.getY()-_y)*( p2.getY() -_y) ); | |||
return distance; | |||
} | |||
==File Structuring== | ==File Structuring== |