I run the code. The results are:
5.0 5.0 1.0
10.0 5.0 10.0
It did make the radius to 10.0, but it still failed.
Why? What's the difference between "this" and an object?
What is "the correct arguments" exactly?
package com.codegym.task.task05.task0521;
/*
Calling a constructor from a constructor
*/
public class Circle {
public double x;
public double y;
public double radius;
public Circle(double x, double y, double radius) {
this.x = x;
this.y = y;
this.radius = radius;
}
public Circle(double x, double y) {
Circle circle = new Circle(x, y, 10);
this.x = x;
this.y = y;
this.radius = circle.radius;
}
public Circle() {
this(5, 5, 1);
}
public static void main(String[] args) {
Circle circle = new Circle();
System.out.println(circle.x + " " + circle.y + " " + circle.radius);
Circle anotherCircle = new Circle(10, 5);
System.out.println(anotherCircle.x + " " + anotherCircle.y + " " + anotherCircle.radius);
}
}