Challenge: Refactor a Coordinate Struct
Tarefa
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.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 4. Capítulo 4
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Suggested prompts:
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Incrível!
Completion taxa melhorada para 4.17
Challenge: Refactor a Coordinate Struct
Deslize para mostrar o menu
Tarefa
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.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 4. Capítulo 4
single