moveWorker()

  1. Use four keys 'H', 'K', 'J', 'L' to move the worker to the left, up, down, right, respectively.
  2. Assume you have an enumeration data type which consists of 4 members { LEFT, UP, DOWN, RIGHT }.
  3. Define a function char NextToWorker(Direction d), which will return the neighbor cell of the worker in the d direction. For example, in the following figure, NextToWorker(LEFT) == 'H' and NextToWorker(UP) == ' '.
  4. Define a function MoveWorker(Direction d).
  5. In your main loop, when the user press the UP key ('K'), and NextToWorker(UP) == ' ', call MoveWorker(d) to move the worker and re-draw.
  6. Handle DOWN, LEFT and RIGHT similarly.
  7. Define a function error_message(char* s = "Warning!") to warn the player if it is not a legal move.