For this SPA you will complete a program to read appointments and print them out in sorted order where appointments are sorted (ordered) by date. The goal of the SPA is to get experience with C++ header and implementation files and separating method and function definitions from their declarations.
You do not have to know any algorithms for putting data in order
("sorting") to do this assignment. Schedule::add
implements a
simple algorithm known as insertion sort in which the code
determines where to place each new item in a collection and then shifts the
remaining items right one position to allow the new item to be
inserted. This does not scale, but you will learn more effective algorithms
in later courses.
To complete this assignment, do the following:
Date
to date.h
,
using date.cpp
to see what methods and attributes are
needed. Note that the definitions of all methods will be
in date.cpp
- all you need to include in date.h
are the prototypes. Ensure the data
(_month
, _day
, and _year
) is
private and that the public interface appears before the private
section. Class Date
will depend on std::string
,
so be sure to add the appropriate #include
.
Do not put using namespace std;
in date.h
. It is rare for a header file to
have using
declarations in it.
Note that writing the prototypes for date.h
should be
straightforward: you can simply copy/paste the appropriate bits of code
from date.cpp
and make minor edits.
Document what class Date
provides to the rest of
the system in terms of its responsibilities. For example, what sorts of
dates can it hold?
earlier
to date.h
.
date.cpp
contains no errors. You will have
errors in the other files, but you should be able to
make date.cpp
error-free at this point.
#ifndef
lines to appointments.h
and
appropriate includes. Do not make changes to the
classes Appointment
and Schedule
. See
the todo example for code to follow.
while
in appointments.cpp
At this point, the entire system should be free of compilation
errors. The program will not build - you still need to define
methods and functions in appointments.cpp
, but there should be
no unrecognized symbols.
test1
. The output should be
05/29/2026: boredom.begin(): start of summer break 11/24/2026: eat turkey 11/28/2026: start winter 16-17 12/21/2026: break for Christmas! 03/06/2027: spring quarter starts in 2027 03/14/2027: pi! 03/05/2028: start of last term for seniors...
test2
. The output should be
ERROR: invalid day in 04/31/2004 ERROR: invalid day in 02/30/1999 ERROR: invalid year in 01/01/1900 02/29/2003: treated as a leap day 05/13/2004: someone's birthday 12/31/3000: end of timeThis tests some of the error checking cases.
main.cpp
.
Do not submit main.cpp
- the handin system is set up to
automatically include that with your solution when it builds. Use
the esubmit
tool, add
each of your source files in any order
(appointments.h
, appointments.cpp
, date.h
,
and date.cpp
), and click on the Submit button. When you
are finished with the code, submit a document to Canvas as directed.
main.cpp
with the new version.
.cpp
file (except
main.cpp
) and select Add filename to CMake
Project