Advertisement
polpoteu

PIO Zad2 PointXY

Oct 24th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. package newpackage2;
  2. import java.awt.*;
  3.  
  4. class PointXY {
  5. private Point point = new Point();
  6.  
  7. public PointXY(int x, int y) {
  8. this.point.x=x;
  9. this.point.y=y;
  10. }
  11.  
  12. public Point getPoint() {
  13. return point;
  14. }
  15.  
  16. public void setPoint(Point point) {
  17. this.point = point;
  18. }
  19.  
  20. @Override
  21. public String toString() {
  22. return "Współrzędne zmiennej to "+ point + '}';
  23. }
  24. public int calculateDistance(PointXY pointDest){
  25. int a2 = (int)java.lang.Math.pow(pointDest.point.x-this.point.x, 2);
  26. int b2 = (int)java.lang.Math.pow(pointDest.point.y-this.point.y, 2);
  27. int distance = (int)java.lang.Math.sqrt(a2+b2);
  28. return distance;
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement