Java Practice It | Self-Check 8.10: distancePoint | classes, encapsulation, instance methods

Опубликовано: 25 Март 2023
на канале: Computer Engineering life
942
7

More practice its:
   • Java | Practice-It | Self Check & Exe...  


Problem:
https://practiceit.cs.washington.edu/...


Question:
Add the following method to the Point class:

public double distance(Point other)

Returns the distance between the current Point object and the given other Point object. The distance between two points is equal to the square root of the sum of the squares of the differences of their x- and y-coordinates. In other words, the distance between two points (x1, y1) and (x2, y2) can be expressed as the square root of (x2 - x1)2 + (y2 - y1)2. Two points with the same (x, y) coordinates should return a distance of 0.0.

public class Point {
int x;
int y;

// // your code goes here

}


На этой странице сайта вы можете посмотреть видео онлайн Java Practice It | Self-Check 8.10: distancePoint | classes, encapsulation, instance methods длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Computer Engineering life 25 Март 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 942 раз и оно понравилось 7 зрителям. Приятного просмотра!