Coursework 3
IN3013/INM173 - Object Oriented Programming in C++
This coursework explores a mixture of inheritance and template classes.
The application is a simple appointment book.
It is due on Tuesday 16th March,
and counts for 12% of the module marks.
For this task, you will be using the Date class from week 3.
Just copy the file date.cc
into the directory containing
your program, and add
#include "date.cc"
near the top of your source file.
- Implement an abstract base class Appointment containing
a time and a string describing the appointment, with a pure virtual method
bool occurs_on(Date d) const;
that says whether the appointment falls on a given day.
You will need to decide how you will represent times.
Document any restrictions you impose.
- Implement derived classes
- SingleAppointment
- for an appointment that falls on a single day.
- DailyAppointment
- for an appointment that occurs every day.
- WeeklyAppointment
- for an appointment that occurs on the same day of each week.
- MonthlyAppointment
- for an appointment that occurs on the same day of each month.
each with a specific definition of occurs_on,
and whatever fields are appropriate.
- Write a function that goes through a sequence of Appointment *
and prints out those that occur on a given day.
- Make your program read the sequence of appointments from a text file.
There are some design issues here.
You cannot simply overload the » operator for Appointment,
because you will want to fill in a larger object,
and you won't know which derived class you want until you have read
at least some of the input.
- Make your program accept two commands from the standard input:
- print all the appointments that fall on a given date (or today).
- add an appointment to the sequence.
You don't have to cope with input errors.
- Make your program save the sequence of appointments to the file
when the end of the standard input is reached (or add a quit command).
(This is much more straightforward than input.)
If you wish, you may work on and submit this coursework in pairs.
Undeclared pairs will be referred to the academic misconduct procedure
- ``We worked together'' will not be an excuse.
A pair should submit a single solution, with both names on it.
A pair submission will obtain approximately 95% of the marks that an
identical single submission would have obtained,
so pairs are expected to do slightly more work than singles:
- The basic specification says not to worry about errors.
However you can make your program more robust by reading each line using
getline,
creating a stringstream from it, and reading from that.
(You'll need to import sstream.)
Then any error will be confined to that line.
Do this, and add simple error reporting.
but even if you don't do this, you can expect a good mark if you do
the basic task successfully and neatly.
Individuals should not do this extra task.
You don't have to what you did (pair or single) for the previous courseworks.