//------------------------------------------------------ // // roomba.cpp // // A small robot simulation program, which describes the // behavior of a simple roomba-like robot. // // Written by: Simon Parsons // 2nd September 2008 // //------------------------------------------------------ // C++ library definitions #include using namespace std; // Variables int x; // The roomba's x co-ordinate int y; // The roomba's y co-ordinate; // Methods void displayPosition() { cout << "Roomba is at: ("; cout << x << ", " << y; cout << ")\n"; } void goNorth() { cout << "Moving north\n"; y = y + 1; } void goSouth() { cout << "Moving south\n"; y = y - 1; } void goEast() { cout << "Moving east\n"; x = x + 1; } void goWest() { cout << "Moving west\n"; x = x - 1; } int main() { cout << "Hello from your living room\n"; // initial position. x = 4; y = 3; displayPosition(); goNorth(); displayPosition(); return 0; }