// restaurantManager.cpp   P. Conrad/J. Atlas   for CISC181, Fall 2004
// Uses a Restaurant object to perform management of a restaurant.
// Very similar to the earlier tables.cpp except that this is an
// object-oriented approach.

#include <iostream>
using std::cout;
using std::cin;
using std::cerr;
using std::endl;
using std::getline;

#include "getThings.h"  // for getFirstCharacter(), getFirstInteger()
#include "restaurant.h"


// Prints the welcome message for the manager
void printWelcome(Restaurant &r)
{
  cout << "Welcome to the restaurant table manager program. \n"
       << "\n"
       << "Because the restaurant owner loves C++, tables in\n"
       << "are numbered from 0 through " << r.getNumberOfTables() -1 << "\n"
       << "\n"
       << "Initially all tables are empty, and can hold up to four guests.\n"
       << endl;
  return;
}

// Prints the menu options for the manager
void printMenu(void)
{
  cout << "\n"
       << "Enter R to reserve a table\n"
       << "      C to clear a table\n"
       << "      P to print status of all tables\n"
       << "      Q to quit" << endl;
  return;
}

// The main loop of the restaurant manager.  Calls functions on
// the Restaurant object to perform the different tasks.
int main(void)
{
  // It would be good to use the command line arguments to dynamically
  // size the Restaurant tables and table guest size

  Restaurant r; // uses the default constructor
  
  printWelcome(r);

  char option;

  printMenu();
  cout << "Enter option: ";
  option = getFirstCharacter(); // instead of cin >> option
  while (option != 'Q' && option != 'q')
    {
      switch (option)
	{
	case 'R': case 'r':
          r.reserveTable();
	  break;
	case 'C': case 'c':
          r.clearTable();
	  break;
	case 'P': case 'p': 
          r.printTableStatus();
	  break;
	default:
	  cout<< "Sorry, option " << option << " not understood.\n";
	  break;
	}
      printMenu();
      cout << "Enter option: ";
      option = getFirstCharacter();
    }
  
  cout << "Thanks.  Bye bye." << endl;
  
  return 0;
}


