piffy icon

PuntoConErrori

piffy | PRO | 01/27/22 03:48:04 PM UTC (Edited) | 0 ⭐ | 2161 👁️ | Never ⏰ | []
Java |

510 B

|

None

|

0 👍

/

0 👎

public class Punto {
        private final double x; 
        private final double y; 
       
        public Punto() {x = 0.0; y = 0.0;}
        public Punto(double x, double y) {this.x = x;this.y = x; }
 
        public double x() { return x; }
        public double y() { return y; }
        
        public double distanzaDa(Punto p) {
            double dx = this.x() - x();
            double dy = this.y() - y();
            return Math.sqrt(dx*dx + dy*dy);
        }
 
        public String toString() { return "(" + x + ", " + y + "}";  } 
 
}

Comments