package javalabs.lab4.third;

public class Point {
    private double _x;
    private double _y;

    public Point(double x, double y) {
        _x = x;
        _y = y;
    }

    public void setX(double x) { _x = x; }
    public void setY(double y) { _y = y; }

    public double getX() { return _x; }
    public double getY() { return _y; }

    public double vectorLengthFromOrigin() {
        return Math.sqrt(_x * _x + _y * _y);
    }

    @Override
    public String toString() {
        return String.format("(%.2f, %.2f)", _x, _y);
    }

    public void displayInfo() {
        System.out.println("--- 2D Точка ---");
        System.out.println("Тип: " + this.getClass().getSimpleName());
        System.out.println("Координаты: " + toString());
        System.out.println("Длина вектора от (0,0): " + String.format("%.2f", vectorLengthFromOrigin()));
        System.out.println("----------------");
    }
}
