A basic appointment-information management program



This is essentially the enhanced version of Programming #5A. Instead of a database for managing DateType objects regarding dates, here we would like to have a database for managing appointments. For this purpose, we need to define and implement an Appointment class and use objects of this Appointment class to store and process the appointment information of people. You will need to use the DateType class and the C++ string class in the implementation of an Appointment class. We’ll then use this Appointment class as a building block in implementing a simple appointment information database program.


What to do:

  1. Download the basic code framework: Download this zip file and unzip it to get a project containing the basic code to work on. You will should copy and paste your own DateType.h and DateType.cpp files from Programming #2 to replace the empty DateType.h and DateType.cpp files included in it.
  2. Understand the design of the Appointment class: Look at the interface (i.e. the member functions and data members) of the Appointment class as defined and commented  in Appointment.h to understand what kind of data are stored in a Appointment object and what kind of services (member functions) an Appointment object can do for you.
  3. Complete the implementation of the Appointment class: Appointment.cpp contains the implementation details of the member functions of the Appointment class. The implementation there is not completed yet. You have to fill in code in Appointment.cpp to complete the implementation of these member functions according to the specification comments of these member functions in Appointment.h. For example, you need to implement the relational operator >  and others like < and <= so that we can compare Appointment objects. For any two Appointment objects, we consider C1 < C2  as true when the appointment date recorded in C1 is less than that in C2. If C1 and C2 have the same appointment day, then the order of C1 and C2 is determined based on the alphabetical order of their full names (i.e. comparing the last name first and then comparing the first name if they happen to have the same last name). In other words, C1 < C2  is true either (i) when the logic expression C1.CompareAppointment (C2) = = GREATER is true or (ii) when the logic expression C1.SameAppointmentDay (C2) = = true  &&  C1.CompareFullName (C2) = = GREATER is true.
  4. Test the implementation of your Appointment class: The main function in AppointmentTest.cpp given to you is intended as the test ground for testing whether your implementation of the Appointment class is sound. At the moment, we have a vector of Appointment objects (initialized to hold 5 Appointment objects) to serve as a appointment-information database. The code in the main function then does some basic operations such as reading the appointment information of 5 persons into the database, display the appointment information of these people from the database, search the database for the appointment information of persons of a particular name, and search the database to find out the appointment information of all people born on a particular date. You should add similar code to extensively test your implementation in Step 3 above.
  5. Incorporate and revise the functions mergeTwoSortedVectors and mergeSort similar to what you did in Programming #3 and #5A into AppointmentTest.cpp to provide the capability of sorting a vector of Appointment objects instead of a vector of double values:  First, make a copy of those two functions from programming #3 or #5A into AppointmentTest.cpp in this project.  Modify the prototype bool mergeTwoSortedVectors(vector<double> & vecA, vector<double> & vecB, vector<double> & vecC) to bool mergeTwoSortedVectors(vector< Appointment > & vecA, vector< Appointment > & vecB, vector< Appointment > & vecC) and  modify the implementation so that it can merge two sorted vectors of Appointment objects. Modify the prototype of bool mergeSort(vector<double> & vecToSort) to bool mergeSort(vector< Appointment > & vecToSort) and modify the implementation so that it can sort a vector of Appointment objects. Add your own code in the main function to create a vector of Appointment objects and then test to verify that the newly modified functions can work well for merging and sorting Appointment objects.
  6. Implement your own very simple appointment information database program in AppointmentDB.cpp: After you are sure your new implementation of the merge sort stuff does work, make a copy of AppointmentTest.cpp in the project folder and name it AppointmentDB.cpp.  Under Visual studio, remove AppointmentTest.cpp from the project and add AppointmentDB.cpp into the project. Then totally rewrite the main function in AppointmentDB.cpp to provide a menu serving as a simple database user interface similar to what you did for Program#5A. Please carefully examine the details provided in the section below on “Detailed specification of the main function in AppointmentDB.cpp”.
  7. Testing and submission: Extensively test all the services provided by your program. When you are sure things are working perfectly, you are done, submit all your source code files (all .h and .cpp files) and the self-evaluation report as a zip file under Canvas.


Detailed specification of the main function in AppointmentDB.cpp:

Overview:  Your main function in Appointment.cpp should provide services to read appointment information from the keyboard or files, save appointment information into files, search for appointment information within a given range of dates, and sort appointments in order. To accomplish these purposes, in the main function we’ll use a vector<Appointment> object as a container in the main memory to store and manage the date information by using various operators and member functions of the Appointment class. See more details below.

Key data structures:

·         To dynamically store the information of appointments, you should declare in your main function ”  vector<Appointment> appointmentDB;  ” to create a local vector for storing Appointment objects.  You should also declare in your main function a local Appointment object like aAppointment, local string objects like “ string  aFirstName, aLAstName;” and  DateType objects like  “ DateType  dBegin, dEnd;  ” for storing temporary date information.

·         Add the line #include <fstream> in the beginning of the .cpp file for file I/O support. In the main function, you should declare a string string filename for storing the file name given by the user. You should declare two file handles ifstream fin; and ofstream fout; for file input/output purposes respectively. You should also declare in your main function local integer variable  “ int  numAppointmentRecords;  ” for temporarily storing the information of the number of date records involved in the file I/O.


Service menu: The main function should set up a loop that would repeatedly display a menu to prompt the user to choose one of the following services:


Implementation of the services:

On each iteration of that loop, the program should read the user’s choice and use a switch statement to do things according to the choice:





You can click the individual member function below to access the related sample code in the online MSDN documents. 

·         Vector class: Non-iterator member functions (no iterators used):


Constructs a vector of a specific size or with elements of a specific value or as a copy of some other vector.


Returns the number of elements in the vector.


Erases the elements of the vector.


Tests if the vector container is empty.


Deletes the element at the end of the vector.


Add an element to the end of the vector.


Specifies a new size for a vector.




Reserves a minimum length of storage for a vector object.


Exchanges the elements of two vectors.



·         Vector class: iterator-related member functions (iterators used):


Returns a random-access iterator to the first element in the container.


Returns a random-access iterator that points just beyond the end of the vector.


Removes an element or a range of elements in a vector from specified positions.


Inserts an element or a number of elements into the vector at a specified position.



·         You can click this link to see the full list of the vector class members.