/* 
 * Author:     Wil Schrader
 * Date:       9/8/2009
 * Version:    1.1
 * Class:      CIT 131 / Fall 2009 
 *
 * Assignment: 2) Navigator
 *                Allow user to move N S E W.
 *                Display current coordinate position and the options.
 */
#include <stdio.h>

/* Main Function */
int main ( void )
{
   int x = 0, y = 0;
   int running = 1;
   char c;

   /* Loop until false */
   while (running) {

      /* Print the current position and the instructions */
      printf( "Current Position = (%d,%d)\n", x, y );
      printf( "Move (N)orth, (S)outh, (E)ast, (W)est, or (Q)uit: " );

      c = getchar();                /* Read a character from the user */
      while ( getchar() != '\n' );  /* Flush the input buffer */

      /* Switch */
      switch ( c ) {
         case 'N':
         case 'n':
            y++;
            break;
         
         case 'S':
         case 's':
            y--;
            break;

         case 'E':
         case 'e':
            x++;
            break;

         case 'W':
         case 'w':
            x--;
            break;

         case 'Q':
         case 'q':
            printf( "Exiting...\n" );
            running = 0;
            break;

      } /* End Switch */

   }/* End While */

   return 0; /* Program ended successfully */

} /* End Main Function */