Package simulation
Class Vector
java.lang.Object
simulation.Vector
public class Vector
extends java.lang.Object
Class describing vector as an array of numbers with additional operations that can be performed on Vectors.
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidaddVector(Vector vector)Add values of different vector to this vector.doublegetX()Get value x of this vector.doublegetY()Get value y of this vector.doublelength(Vector vector)Get a length of the vector.voidmultiply(double num)Multiply a vector by a scalar.voidmultiply(Vector vector)Multiply this vectors values by different vector's values.voidsetVector(Vector vector)Set vector values to be equal to other vector.voidsetX(double x)Set value x of this vector.voidsetY(double y)Set value y of this vector.java.lang.StringtoString()Generate string representation of object.
-
Constructor Details
-
Method Details
-
getX
public double getX()Get value x of this vector.- Returns:
- x value of the vector.
-
setX
public void setX(double x)Set value x of this vector.- Parameters:
x- desired x value of the vector.
-
getY
public double getY()Get value y of this vector.- Returns:
- y value of the vector.
-
toString
public java.lang.String toString()Generate string representation of object.- Overrides:
toStringin classjava.lang.Object- Returns:
- string containing x and y value of the vector.
-
setY
public void setY(double y)Set value y of this vector.- Parameters:
y- desired y value of the vector.
-
setVector
Set vector values to be equal to other vector.- Parameters:
vector- a vector to be used.
-
addVector
Add values of different vector to this vector.- Parameters:
vector- a vector to be added.
-
multiply
Multiply this vectors values by different vector's values.- Parameters:
vector- a vector to be multiplied by.
-
multiply
public void multiply(double num)Multiply a vector by a scalar.- Parameters:
num- a scalar to be used in multiplication.
-
length
Get a length of the vector.- Parameters:
vector- vector to be used in length calculations.- Returns:
- length of given vector.
-