Lab 4

Functions & Parameter passing

In this lab we will learn how to make use of functions to make the code more modular and readable. We will do that by modifying the code for a game of coinswap.  

You will have to move code in the main function to appropriate function definitions and call the functions 

Coin Swap 

 The Game

 ----------

 The playing board starting position is:

     1  2  3  4  5

     X  X     O  O

 The object of the game is to swap the X and O pieces, ending up with:

     1  2  3  4  5

     O  O     X  X

 X can only move a single square to the right, or jump an O to the right

 into an open square.  O can only move a single square to the left, or

 jump an X to the left into an open square.  The ' ' denotes a blank space.

Initially assume that the user only makes valid moves. For the extra credit 

question, you are required to check if a given move is valid

 

 Given

 -----

 Starter code coinswap.cpp.

 

  Note: Currently all the functions are commented out.  When you have a section you want to test,

  uncomment it in order to compile, run and test it.  Remember to uncomment the region containing

  the function definitions so that the compiler can see it!

Grading

 0.0 points: Implement functions displayIdentifyingInformation() and displayBoard() 

 0.5 points: Implement function displayBoard() 

 0.5 points: Implement function getFromAndToPositions()

 0.5 points: Implement function makeMove()

 0.5 points: Implement function gameIsOver()

 1.0 points: Implement function moveIsValid()