/* * Dog location Version 2 */ #include class Dog { public: short int x,y; void Home(void); void MoveX(int amount); void MoveY(int amount); }; /* * Methods */ // Send a Dog home (0,0) // void Dog::Home(void) { x = 0; y = 0; } // Move a Dog in the X direction // void Dog::MoveX(int amount) { x += amount; } // Move a Dog in the Y direction // void Dog::MoveY(int amount) { y += amount; } void main() { Dog rover, spot; rover.x = 5; rover.y = 6; spot.x = 10; spot.y = 3; cout << "Rover is at (" << rover.x << "," << rover.y << ")" << endl; cout << "Spot is at (" << spot.x << "," << spot.y << ")" << endl; rover.MoveX(1); cout << "Rover is at (" << rover.x << "," << rover.y << ")" << endl; rover.MoveY(-3); cout << "Rover is at (" << rover.x << "," << rover.y << ")" << endl; spot.Home(); cout << "Spot is at (" << spot.x << "," << spot.y << ")" << endl; }