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

bookChallenge: Refactor a Coordinate Struct

Tehtävä

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.

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 4. Luku 4
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

Suggested prompts:

Can you explain this in simpler terms?

What are the main points I should remember?

Can you give me an example?

close

bookChallenge: Refactor a Coordinate Struct

Pyyhkäise näyttääksesi valikon

Tehtävä

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.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 4. Luku 4
single

single

some-alt