title: Calculate car movement and distance with C++ classes
body: <p>This program compiles however, I need to get this function to move on the x &amp; y coordinate and then output the total distance traveled. The xCord moves it right and left while the yCord moves it up and down. I think I need to update my int Taxicab::getDistanceTraveled(), void Taxicab::moveX(int getX),  &amp; void Taxicab::moveX(int getX). But for the life of me can't figure out what to do to get it to update properly. When I compile and run it gives me 132617596 for cab1 distance travelled and 0 for the Y coordinate on cab2. Thanks for the help!  </p>
  
  <pre><code>#ifndef TAXI_CPP
  #define TAXI_CPP
  
  class Taxicab
  {
  private:
      int xCord;
      int yCord;
      int totalDist;
  public:
      Taxicab(); //default constructor
      Taxicab(int, int); //overload constructor
      int getX(); //returns X coordinate
      int getY(); //returns Y coordinate
      int getDistanceTraveled(); //returns distance calculation
      void moveX(int); //moves X left or right
      void moveY(int); //moves Y left or right 
  };
  #endif // !TAXI_CPP
  
  
  
  
  #include "Taxi.h"
  #include &lt;iostream&gt; 
  #include &lt;math.h&gt;
  #include &lt;cstdlib&gt;
  
  using std::cout;
  using std::cin;
  using std::endl;
  using std::abs;
  
  Taxicab::Taxicab() //default constructor
  {
  
  }
  
  Taxicab::Taxicab(int xCord, int yCord) //overload constructor
  {
      xCord = 0; //initialize to 0
      yCord = 0; //initialize to 0
      totalDist = 0; //initialize to 0
  }
  
  int Taxicab::getX()
  {
      return xCord; //return x coordinate
  }
  
  int Taxicab::getY()
  {
      return yCord; //return y coordinate
  }
  
  void Taxicab::moveX(int getX)
  {
      int moveX = 0;
      moveX = moveX + getX;
  }
  
  void Taxicab::moveY(int getY)
  {
      int moveY = 0;
      moveY = moveY + getY;
  }
  
  int Taxicab::getDistanceTraveled()
  {
      return abs(xCord) + abs(yCord);
  }
  
  
  #include &lt;iostream&gt;
  #include "Taxi.h"
  #include &lt;math.h&gt;
  
  using std::cout;
  using std::cin;
  using std::endl;
  
  int main()
  {
      Taxicab cab1;
      Taxicab cab2(5, -8);
      cab1.moveX(3);
      cab1.moveY(-4);
      cab1.moveX(-1);
      cout &lt;&lt; cab1.getDistanceTraveled() &lt;&lt; endl;
      cab2.moveY(7);
      cout &lt;&lt; cab2.getY() &lt;&lt; endl;
  }
  </code></pre>