Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Point {
- private double x;
- private double y;
- public Point(){
- x= 0.0;
- y= 0.0;
- }
- public Point(double vx, double vy){
- x = vx;
- y = vy;
- }
- public double getX(){
- return x;
- }
- public double getY(){
- return y;
- }
- public double distanceTo(Point p){
- return Math.sqrt(Math.pow(x-p.x, 2) + Math.pow(y-p.y, 2));
- }
- public static void main(String args[]){
- Point a,b;
- a = new Point();
- b = new Point(2.0,2.0);
- double d;
- d=a.distanceTo(b);
- System.out.println("La distance est : " + d);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement