Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Challenge: Refactor a Coordinate Struct | Composition, Inheritance, and Refactoring
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C# OOP Class Construction Drills

bookChallenge: Refactor a Coordinate Struct

Aufgabe

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 Coordinate that has X and Y properties.
  • Implement a constructor that accepts values for X and Y.
  • Add a method named DistanceTo that takes another Coordinate object 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 X and Y values.

Lösung

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 4. Kapitel 4
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

close

bookChallenge: Refactor a Coordinate Struct

Swipe um das Menü anzuzeigen

Aufgabe

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 Coordinate that has X and Y properties.
  • Implement a constructor that accepts values for X and Y.
  • Add a method named DistanceTo that takes another Coordinate object 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 X and Y values.

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 4. Kapitel 4
single

single

some-alt