public class Circle {
public final double x;
public final double y;
public final double radius;
public Circle(double x, double y, double radius) {
this.x = x;
this.y = y;
this.radius = radius;
}
public double getLength() {
return 2 * Math.PI * radius; // C = 2пR
}
public double getArea() {
return Math.PI * radius * radius; // S = пR^2
}
public double getDistanceTo(Circle other) {
double dx = this.x - other.x;
double dy = this.y - other.y;
return Math.sqrt(dx * dx + dy * dy);
}
public static void main(String[] args) {
// Создаем круги
Circle a = new Circle(2, 3, 5);
Circle b = new Circle(3, 5, 8);
// Делаем расчеты и тут же их выводим
System.out.printf("C1 = %f, S1 = %f%n", a.getLength(), a.getArea());
System.out.printf("C2 = %f, S2 = %f%n", b.getLength(), b.getArea());
System.out.printf("Distance = %f%n", a.getDistanceTo(b));
}
}