721
edits
m (→Homework) |
m (→Homework) |
||
Line 13: | Line 13: | ||
# As a second task, I want you to extend the code of the Point2D to include a function to measure the distance between two points in 2D space. Do you remember the "Theorem of Pythagoras"? | # As a second task, I want you to extend the code of the Point2D to include a function to measure the distance between two points in 2D space. Do you remember the "Theorem of Pythagoras"? | ||
The function body should look like this: | The function body should look like this: | ||
<source lang=" | <source lang="c++" line start="1" highlight="4">float distanceToOtherPoint(Point2D otherPoint) { | ||
float distance = ... // calculate distance here | float distance = ... // calculate distance here | ||
return distance; | return distance; | ||
}</source> | }</source> | ||
Include that function in our Point2D class and make it calculate the distance! | Include that function in our Point2D class and make it calculate the distance! |