Challenge: Refactor a Coordinate Struct
Taak
Swipe to start coding
Refactor the provided Coordinate struct into a class and add a method to calculate the distance to another Coordinate object.
- Replace the struct with a class named
Coordinatethat hasXandYproperties. - Implement a constructor that accepts values for
XandY. - Add a method named
DistanceTothat takes anotherCoordinateobject as a parameter and returns the Euclidean distance between the two coordinates. - The distance is calculated as the square root of the sum of the squared differences of the
XandYvalues.
Oplossing
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 4. Hoofdstuk 4
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Suggested prompts:
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Geweldig!
Completion tarief verbeterd naar 4.17
Challenge: Refactor a Coordinate Struct
Veeg om het menu te tonen
Taak
Swipe to start coding
Refactor the provided Coordinate struct into a class and add a method to calculate the distance to another Coordinate object.
- Replace the struct with a class named
Coordinatethat hasXandYproperties. - Implement a constructor that accepts values for
XandY. - Add a method named
DistanceTothat takes anotherCoordinateobject as a parameter and returns the Euclidean distance between the two coordinates. - The distance is calculated as the square root of the sum of the squared differences of the
XandYvalues.
Oplossing
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 4. Hoofdstuk 4
single