Challenge: Coordinates of a Point
This lesson brings you a challenge to solve.
We'll cover the following
Problem statement
Define a 2 dimensional Point
with coordinates X
and Y
as a struct. Implement a method Abs()
that calculates the length of the vector represented by a Point, and a method Scale ()
that multiplies the coordinates of a point with a scale factor.
Note:
Point
is the struct type, andX
andY
are its fields. Do not change the name of these variables.
Try to implement the function below. Feel free to view the solution, after giving some shots. Good Luck!
Get hands-on with 1400+ tech skills courses.