/* SwitchSecond.cpp - Coins swapping program. The playing board is 5 squares. Think of one coin each on the two left-most squares, with "heads" shown on those coins. The middle square is blank, and the two right-most squares each have a coin, with "tails" shown. The object is to swap the coins. For the sake of the program, we will represent "heads" as 'X', and "tails" as 'O'. The starting board configuration is then: XX OO and the final board configuration is: OO XX An X can only move to the right, and an O can only move to the left. On each move you can move any piece into an adjacent square, or you can jump over an opposite piece into a blank square. Thus an X can jump an O, but an X cannot jump another X (and similarly for O jumping X). What remains to be done in this program is to have the completed board displayed after the last move. */ // declare variables char p1 = 'X'; // The 5 'p' variables are the 5 pieces on the game board char p2 = 'X'; char p3 = ' '; char p4 = 'O'; char p5 = 'O'; #include using namespace std; // display identifying information void displayIDinformation() { } // display instructions void displayInstructions(); { } // display board void displayBoard(); { } // Prompt for and get the position of the piece to move void promptAndGetPieceToMove(); { } // Move the piece void moveThePiece(); { } // See if we're done yet void seeIfWereDoneYet() { } int main() { // declare variables bool notDone = true; // flag telling whether or not the game is done int pieceToMove = 0; // piece to move position char pieceBeingMoved; // piece to move character char neighbor; // character stored in neighbor, in direction to move char jumpDestination; // character stored in destination if a jump is made int destination; // destination square number for move // display identifying information displayIDinformation(); // display instructions displayInstructions(); while ( notDone) { // display board displayBoard(); // Prompt for and get the position of the piece to move promptAndGetPieceToMove(); // Move the piece, assuming it is a valid move moveThePiece(); // See if we're done yet seeIfWereDoneYet(); } return 0; }