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 void
addVector(Vector vector)
Add values of different vector to this vector.double
getX()
Get value x of this vector.double
getY()
Get value y of this vector.double
length(Vector vector)
Get a length of the vector.void
multiply(double num)
Multiply a vector by a scalar.void
multiply(Vector vector)
Multiply this vectors values by different vector's values.void
setVector(Vector vector)
Set vector values to be equal to other vector.void
setX(double x)
Set value x of this vector.void
setY(double y)
Set value y of this vector.java.lang.String
toString()
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:
toString
in 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.
-