セクション 4. 章 4
single
Challenge: Refactor a Coordinate Struct
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
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.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 4. 章 4
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください