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

    Constructors 
    Constructor Description
    Vector​(double x, double y)
    Create new object from given x and y values.
    Vector​(Vector vector)
    Clone a vector.
  • 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Vector

      public Vector​(double x, double y)
      Create new object from given x and y values.
      Parameters:
      x - x value of the vector.
      y - y value of the vector.
    • Vector

      public Vector​(Vector vector)
      Clone a vector.
      Parameters:
      vector - vector to be cloned.
  • 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 class java.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

      public void setVector​(Vector vector)
      Set vector values to be equal to other vector.
      Parameters:
      vector - a vector to be used.
    • addVector

      public void addVector​(Vector vector)
      Add values of different vector to this vector.
      Parameters:
      vector - a vector to be added.
    • multiply

      public void multiply​(Vector vector)
      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

      public double length​(Vector vector)
      Get a length of the vector.
      Parameters:
      vector - vector to be used in length calculations.
      Returns:
      length of given vector.