package W09H03_InterfacesAdvanced;

public class Point implements Encryptable<Point> {

    public double x;
    public double y;

    public Point(double x, double y) {
        this.x = x;
        this.y = y;
    }

    
    @Override
    public Point encrypt() { // encripta doubles he intercambia x e y
        Point p = new Point(BadEncryption.encryptDouble(y),
                            BadEncryption.encryptDouble(x));
        
        return p;
    }

    @Override
    public Point decrypt() { // desencripta doubles he intercambia x e y
        Point p = new Point(BadEncryption.decryptDouble(y),
                            BadEncryption.decryptDouble(x));
        
        return p;
    }

    public void invertCoordinates() {
        double aux = x; // x es implicitamente this.x
        x = y;
        y = aux;
    }

    @Override
    public String toString() {
        return "(" + x + "," + y + ")";
    }
}
