CS 250 Computer Programming and Problem Solving - FALL 1998 |
---|
[ Home | Syllabus | Notes | Glossary | CS250 WEB Version Home Page ]
Object Oriented Design:
Case Study: Doctor Scheduling
Version 1:
Top Down Design.
main { initialize the scheduler at beginning of day Make appointments for the doctors for today Print appointments made today finalize at end of day }
//###################### // Scheduler is responsible for making appointments with patients // and recording them in the doctor's daily schedule // and Printing out these schedules // keeps a reference to all doctors for this purpose //###################### class Scheduler { public: Scheduler( Doctor * docs, int NumDoctors); // Scheduler keeps track of appointments for all doctors // A list of doctors is passed and a reference to this list is kept // in this object void PrintAllAppointments( const char * fileName ); // PRE: fileName is a legtimate file name // POST: the daily schedule of all doctors is printed to "fileName" void ScheduleAllAppointments(); // runs all day scheduling appointments // returns when all patients have be scheduled for this day private: Doctor * doctors; // points to first element in array of doctors // notice that there is only one copy of the doctor object, but we can // refer to it using the pointer and so can update the doctor/s schedule // we could have made a copy of the doctor objects - // but then they could not be accessed or changed outside (consistently) int NumDoctors; // keeps size of array of Doctors };
#include "doctors.h" // contains all specifications int main() { const int NumDoctors = 5; // Keep the Doctor objects here Doctor doctorArray[NumDoctors]; cout << "Doctors Office Scheduling Program\n\n"; //initialize the scheduler at beginning of day Scheduler officeSchedule( doctorArray, NumDoctors ); //Make appointments for the doctors for today officeSchedule.ScheduleAllAppointments(); //Print appointments made today officeSchedule.PrintAllAppointments( "appts.txt" );
//finalize at end of day return 0; }
// in doctor.h add minimal Doctor class class Doctor{ public: Doctor(); };
// in doctor.cpp, add empty function definitions Doctor::Doctor(){} Scheduler::Scheduler( Doctor * docs, int num ) {} void Scheduler::PrintAllAppointments(const char * fileName) {} void Scheduler::ScheduleAllAppointments() {}
(here is the code at this point)