← all problems

Vector2D.Magnitude 🌶️

Below is the definition of a Vector2D class, representing a two dimensional vector - an arrow pointing from the origin of an X-Y coordinate plane to some point in that plane. Its fields are a pair of x and y coordinates.

You will write an object method that finds the length (sometimes called the magnitude) of the vector.

Vector2D.java — the class below is already written; you're only completing the method in the editable box.

class Vector2D {
    private double x;
private double y;

    public Vector2D() {
        x = 0.0; 
        y = 0.0;
    }

    public Vector2D(double x, double y) {
        this.x = x;
        this.y = y;
    }
    // ---- write your method below ----
}