(Latest Revision: 03/24/2010)
[03/24/2010: changed iostream.h to iostream to eliminate compiler warning about "deprecated header"]

SOURCE FILE: designIdeas



/* This is a sample of how some level one-two code might look.
You don't have to do anything like this -- it is just an example
of one approach. */

#include <iostream>
#include <string>

/* 

   The plan is to have an 'interpreter' class to translate each
   command string into an internal representation more convenient
   for use by the program.  

   (You'd need to make 'stub' interpret.h and interpret.cpp
   files, and fill in more detail as you continue to deeper
   levels of the program.)

*/

#include "interpret.h"

/*

    Here the idea is to have a clinic class that executes the
    commands -- the easy-to-understand commands that are output
    by the translator.

   (You need to make 'stub' clinic.h and clinic.cpp files, and
   fill in more detail as you continue to deeper levels of the
   program.)


*/

#include "clinic.h"

/* 

Read, echo, and Process a series of commands from standard input.

The last command will be "Stop".  Generally, commands are
multi-word.  The commands are separated out, one to a line.

Place delimiters on standard output before and after the output
of each command.

*/
/* ######################### */
/* MAIN PROGRAM */
/* ######################### */
int main()
{
  clinicClass clinic ; 
  InterpreterClass interpreter ;
  string commandStr ;
  commandType  command ;

  cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" ;
  cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl ;
  do
  {
     getline(cin, commandStr) ;
     cout << commandStr << endl ;
     interpreter.StoreCommandStr(commandStr) ;
     interpreter.Interpret() ;
     command = interpreter.GetCommand() ;
     if (!command.stop) 
     { 
       clinic.execCommand(command) ;
       cout << endl << clinic.GetMessage() << endl ;
       clinic.showState() ;
     }
  cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" ;
  cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << endl ;
  }
  while (!command.stop) ;
  return 0 ;
}

InterpreterClass::Interpret() calls:

void InterpreterClass::GetPerson(string & comTailStr)  (doctor/patient)
void InterpreterClass::GetCategory(string & comTailStr) (check-in/-out)
void InterpreterClass::GetLastName(string & comTailStr) 
void InterpreterClass::GetRoomNum(string & comTailStr) 
void InterpreterClass::GetSpecCode(string & comTailStr) 
void InterpreterClass::GetAge(string & comTailStr) 
void InterpreterClass::GetPriorityCode(string & comTailStr) 

(However 'interpret' calls only *some* of the above for each
 command it translates.  It calls only the ones that are needed
 for the command it is processing.)

InterpreterClass::GetCommand() returns a struct that contains the
translation of the command string.  The idea is that the fields
of the struct are convenient representations of the parts of the
command string.

clinicClass::execCommand(commandType com) calls:


string clinicClass::docCkIn(commandType command) 
string clinicClass::docCkOut(commandType com) 
string clinicClass::patCkIn(commandType command) 
string clinicClass::patCkOut(commandType com)

(Actually execCommand calls exactly one of these, depending on
the command.)

The four functions above return a message, which execCommand uses
to set a data member of the class.  The call to
clinicClass::GetMessage() returns that message string.  


clinicClass::showState() calls:

  void clinicClass::showRooms() 
  void clinicClass::showDeques()