Challenge: Refactor a Coordinate Struct
Tarea
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.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 4. Capítulo 4
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Suggested prompts:
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Genial!
Completion tasa mejorada a 4.17
Challenge: Refactor a Coordinate Struct
Desliza para mostrar el menú
Tarea
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.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 4. Capítulo 4
single