Class Vector#9051

Class Vector

1 second
128 megabytes
Very easy

Create the class Vector with three private integer members: x, y, and z.

Implement the following in the class:

Submit only the class implementation.

class Vector // Java
{
  private int x, y, z;
  Vector(); // default constructor, sets members to 0
  Vector(int x, int y, int z); // constructor with parameters (coordinates)
  Vector(Vector v); // copy constructor

  void setX(int x); // sets the value of x
  void setY(int y); // sets the value of y
  void setZ(int z); // sets the value of z

  int getX(); // returns the x coordinate
  int getY(); // returns the y coordinate
  int getZ(); // returns the z coordinate

  public double length(); // returns the length of the vector
  public void Out(); // prints the vector coordinates, separated by spaces
}