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;
}
@@ -696,24 +696,87 @@
 on.getX();%0A%0A
+            System.out.println(%22**comparing %22+x1+%22 and %22+x2);%0A%0A
             
@@ -832,18 +832,19 @@
 ity.
-setX(x1 -1
+decrementX(
 );%0A 
@@ -882,18 +882,19 @@
 ity.
-setX(x2 +1
+incrementX(
 );%0A 
@@ -1018,18 +1018,19 @@
 ity.
-setX(x1 +1
+incrementX(
 );%0A 
@@ -1072,18 +1072,19 @@
 ity.
-setX(x2 -1
+decrementX(
 );%0A 
@@ -1200,24 +1200,87 @@
 on.getY();%0A%0A
+            System.out.println(%22**comparing %22+y1+%22 and %22+y2);%0A%0A
             
@@ -1336,18 +1336,19 @@
 ity.
-setY(y1 -1
+decrementY(
 );%0A 
@@ -1386,18 +1386,19 @@
 ity.
-setY(y2 +1
+incrementY(
 );%0A 
@@ -1522,18 +1522,19 @@
 ity.
-setY(y1 +1
+incrementY(
 );%0A 
@@ -1576,18 +1576,19 @@
 ity.
-setY(y2 -1
+decrementY(
 );%0A 
@@ -1704,24 +1704,87 @@
 on.getZ();%0A%0A
+            System.out.println(%22**comparing %22+z1+%22 and %22+z2);%0A%0A
             
@@ -1840,18 +1840,19 @@
 ity.
-setZ(z1 -1
+decrementZ(
 );%0A 
@@ -1890,18 +1890,19 @@
 ity.
-setZ(z2 +1
+incrementZ(
 );%0A 
@@ -2026,18 +2026,19 @@
 ity.
-setZ(z1 +1
+incrementZ(
 );%0A 
@@ -2080,18 +2080,19 @@
 ity.
-setZ(z2 -1
+decrementZ(
 );%0A 

Update Moon.java