//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Example 3.2 on page 54
//  Using polymorphism

public class Pr0302
{ public static void main(String[] args) 
  { ColoredPoint p = new ColoredPoint(2,3,"green");
    System.out.println("p = " + p);
    Point q = new Point(-2,0);
    System.out.println("q = " + q);
    System.out.println("distance(p,q) = " + distance(p,q));
  }

  private static double distance(Point p, Point q)
  { double dx = p.getX() - q.getX();
    double dy = p.getY() - q.getY();
    return Math.sqrt(dx*dx + dy*dy);
  }
}
