public class WrongPoint {
    private double x; // Se garantiza que los atributos se inicializan a 0
    private double y; // No asi con las variables locales de un metodo
                    // Una variable local no inicializada -> Error compilacion
    public WrongPoint(double x) {
        this.x = x;
        System.out.println("Constructing " + this);
        System.out.println("(I'm the WrongPoint(double) constructor)");
    }
    /*
    public WrongPoint(double x, double y) {
        WrongPoint(x);
        this.y = y;
        // ERR: Cannot find symbol: method WrongPoint(double)
        // Tiene que ser this()
    }
    */
    public WrongPoint(double x, double y) {
        this(x); // Invoco al constructor WrongPoint(double)
        this.y = y;
        System.out.println("Constructing " + this);
        System.out.println("(I'm the WrongPoint(double, double) constructor)");
    }
    public WrongPoint(int x, int y) {
        this.x = x;
        this.y = y;
        System.out.println("Constructing " + this);
        System.out.println("(I'm the WrongPoint(int, int) constructor)");
        // "Using this as parameter can be dangerous in the contructor
        // because the object is not fully initialized."
        // (Aunque no tendria que passar nada porque ya lo he inicializado.)
        // Pero me sirve para demostrar que se pueden invocar otros
        // metodos de la clase (en este caso el toString()).
    }
    public double getX() {
        return this.x;
    }
    public double getY() {
        return this.y;
    }
    public void setX(double x) {
        this.x = x;
    }
    public void setY(double y) {
        this.y = y;
    }
    @Override
    public String toString() {
        return "(" + this.x + "," + this.y + ")";
    }
}
