Design Ideas, call chains, data elements



/* This is a sketch of the call hierarchy 
   of one solution to the problem */

int main()
  getline(cin, commandStr)  
  interpreter.StoreCommandStr(commandStr)  
  interpreter.Interpret()  
    GetPerson(comTailStr)  
      decoder.personCode(personStr)  
      comTailStr.substr()  
    GetCategory(comTailStr)  
      decoder.categCode(categStr)  
      comTailStr.substr()  
    GetLastName(comTailStr)  
      comTailStr.substr()  
    GetRoomNum(comTailStr)  
      comTailStr.substr()  
    GetSpecCode(comTailStr)  
      decoder.spcltyCode(specStr)  
      comTailStr.substr()  
    GetAge(comTailStr)  
    GetPriorityCode(comTailStr)  
      decoder.ptyCode(priorStr)  
      comTailStr.substr()  

  interpreter.GetCommand()  

  clinic.execCommand(command)  
    docCkIn(com)  
      decoder.spcltyToString(doctor.specialty) 
    docCkOut(com)  
      room[indexOf(com.roomNum)].doctor.clear()  
      ackDocCkOutMsg(docWhoLeft, com.roomNum)  
      handleDocWithDeq(docWhoLeft, com.roomNum)  
        docWithDeqMsg()
        room[indexOf(roomNum)].deque.isEmpty()
        room[indexOf(roomNum)].deque.Retrieve(1, patient, ignore)  
        room[indexOf(roomNum)].deque.RemoveFromFront(ignore)  
        reassignMsg(docWhoLeft, patient, roomNum)  
        patCkIn(patient, message, ignore)  

    patCkIn(com)  
      patCkIn(patient, message, success)  
        applyRules (patient, success)  
          isEmpty()  
          noDocsMsg(patient)   
          youAreYoungMsg()  
          youAreAdolescentMsg()   
          youAreAdultMsg()  
          findDocs(specSet, roomSet)  
            isMemberSpec(room[roomIdx].doctor.specialty, specSet)
          isEmptyRoomSet(roomSet)
            isMemberRoom(i, roomSet)
          firstFallBackMsg()   
          findMinDeque(roomSet)  
            isMemberRoom(roomOf(curPos), roomSet)
            room[i].deque.Length()
          docYouGotMsg(patient, assignedRoom)  
          room[indexOf(assignedRoom)].deque.AddToRear(patient, insertOK)  
          room[indexOf(assignedRoom)].deque.AddToFront(patient, insertOK)  

    patCkOut(com)  
      room[indexOf(com.roomNum)].deque.Retrieve(1, patient, success)  
      patCkOut(com.lastName, message, com.roomNum)  
        room[indexOf(roomNum)].deque.RemoveFromFront(ok)  
        okPatCkOutMsg(lastName, roomNum)  
      abortPatCkOutMsg(com.lastName,  com.roomNum)  

  clinic.GetMessage()
  clinic.showState()  
    showRooms()  
      room[indexOf(rmNum)].isFree
      room[indexOf(rmNum)].printFreeFlag(DISP_WIDTH)
      room[indexOf(rmNum)].doctor.printName(DISP_WIDTH)
      room[indexOf(rmNum)].doctor.printSpec(DISP_WIDTH)
      makeDivider()  

    showDeques()  
      maxLength()
        room[indexOf(rmNum)].deque.Length()  
      makeDivider()  
      room[id].deque.Retrieve(level, buf.patient[id], buf.exists[id])  
      printDeqLev(buf)  
        buf.exists[id]
        buf.patient[id].printName(DISP_WIDTH)  
        printStr(string(""),DISP_WIDTH)  
        buf.patient[id].printAge(DISP_WIDTH)  
        buf.patient[id].printSpec(DISP_WIDTH)  
        buf.patient[id].printPty(DISP_WIDTH)





Possible Data Elements

Clinic:
  array of rooms
  number of doctors
  current message

Room:
  free flag
  doctor occupant
  deque of patients

Doctor:
  last name
  specialty
  room request

Patient:
  last name
  age
  speciality request
  priority request

Command:
  bool stop
  person (doctor or patient)
  category (check-in or check-out)
  last name
  age
  room number
  specialty
  priority