package eecs2030.lab2; /** * A class that represents two dimensional spatial vectors (a direction and a * magnitude). Every vector has a real-valued x-component and a y-component. The * class provides some basic mathematical operations such as vector addition and * subtraction, and scalar multiplicaton. * * @author EECS2030 Fall 2016 * */ public final class Vector2 { private double x; private double y; /** * Returns the x component of the vector. * * @return the x component of the vector. */ public double getX() { return this.x; } /** * Returns the y component of the vector. * * @return the y component of the vector. */ public double getY() { return this.y; } /** * Returns a string representation of the vector. The string is the name of * the vector, followed by the comma separated components of the vector * inside parentheses. * * @return a string representation of the vector */ @Override public String toString() { return "(" + this.getX() + ", " + this.getY() + ")"; } }