public class Moon
{
    public Moon (int x, int y, int z)
    {
        _position = new Coordinate(x, y, z);
        _velocity = new Velocity();  // the x, y, and z velocity of each moon starts at 0.
    }
    
    public final Coordinate getPosition ()
    {
        return _position;
    }

    public final Velocity getVelocity ()
    {
        return _velocity;
    }

    /*
     * On each axis (x, y, and z), the velocity of each moon changes by
     * exactly +1 or -1 to pull the moons together.
     */

    public final void applyGravity (Moon otherMoon)
    {
        if (!this.equals(otherMoon))
        {
            int x1 = _position.getX();
            int x2 = otherMoon._position.getX();

            if (x1 < x2)
            {
                _velocity.setX(x1 -1);
                otherMoon._velocity.setX(x2 +1);
            }
            else
            {
                if (x1 > x2)
                {
                    _velocity.setX(x1 +1);
                    otherMoon._velocity.setX(x2 -1);
                }
            }

            int y1 = _position.getY();
            int y2 = otherMoon._position.getY();

            if (y1 < y2)
            {
                _velocity.setY(y1 -1);
                otherMoon._velocity.setY(y2 +1);
            }
            else
            {
                if (y1 > y2)
                {
                    _velocity.setY(y1 +1);
                    otherMoon._velocity.setY(y2 -1);
                }
            }

            int z1 = _position.getZ();
            int z2 = otherMoon._position.getZ();

            if (z1 < z2)
            {
                _velocity.setZ(z1 -1);
                otherMoon._velocity.setZ(z2 +1);
            }
            else
            {
                if (z1 > z2)
                {
                    _velocity.setZ(z1 +1);
                    otherMoon._velocity.setZ(z2 -1);
                }
            }
        }
    }

    @Override
    public String toString ()
    {
        return "Moon: "+_position+" and "+_velocity;
    }

    private Coordinate _position;
    private Velocity _velocity;
}
@@ -719,17 +719,17 @@
  if (x1 
-%3C
+%3E
  x2)%0A   
@@ -887,33 +887,33 @@
          if (x1 
-%3E
+%3C
  x2)%0A           
@@ -1156,17 +1156,17 @@
  if (y1 
-%3C
+%3E
  y2)%0A   
@@ -1324,33 +1324,33 @@
          if (y1 
-%3E
+%3C
  y2)%0A           
@@ -1593,17 +1593,17 @@
  if (z1 
-%3C
+%3E
  z2)%0A   
@@ -1761,33 +1761,33 @@
          if (z1 
-%3E
+%3C
  z2)%0A           

Update Moon.java