Advertisement
piffy

PuntoConErrori

Aug 15th, 2021 (edited)
1,701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. public class Punto {
  2.         private final double x;
  3.         private final double y;
  4.        
  5.         public Punto() {x = 0.0; y = 0.0;}
  6.         public Punto(double x, double y) {this.x = x;this.y = x; }
  7.  
  8.         public double x() { return x; }
  9.         public double y() { return y; }
  10.        
  11.         public double distanzaDa(Punto p) {
  12.             double dx = this.x() - x();
  13.             double dy = this.y() - y();
  14.             return Math.sqrt(dx*dx + dy*dy);
  15.         }
  16.  
  17.         public String toString() { return "(" + x + ", " + y + "}";  }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement