abstract class Shape {
double x, y;
Shape(double x, double y) {
this.x = x;
this.y = y;
}
}
class Circle extends Shape {
Circle(double x, double y) {
super(x, y);
}
}
class Rectangle extends Shape {
Rectangle(double x, double y) {
super(x, y);
}
}
class Triangle extends Shape {
Triangle(double x, double y) {
super(x, y);
}
}
public class Main {
static double distance(Shape a, Shape b) {
return Math.sqrt(
Math.pow(a.x - b.x, 2) +
Math.pow(a.y - b.y, 2)
);
}
public static void main(String[] args) {
Circle a = new Circle(0, 0);
Rectangle b = new Rectangle(3, 4);
Triangle c = new Triangle(6, 8);
System.out.println(distance(a, b));
System.out.println(distance(b, c));
}
}