#include "TimeTable.h" const unsigned int numDays = 7; const unsigned int numHours = 24; //------------------------------------------------------------------------- TimeTable::TimeTable() { allocateArray(); } //------------------------------------------------------------------------- TimeTable::TimeTable( const TimeTable& rhs ) { allocateArray(); *this = rhs; } //------------------------------------------------------------------------- void TimeTable::allocateArray() { appointments = new Appointment*[numDays]; for ( unsigned int day = 0; day < numDays; day++ ) { appointments[day] = new Appointment[numHours]; } } //------------------------------------------------------------------------- TimeTable::~TimeTable() { for ( unsigned int day = 0; day < numDays; day++ ) { delete[] appointments[day]; } delete[] appointments; } //------------------------------------------------------------------------- TimeTable& TimeTable::operator=( const TimeTable& rhs ) { for ( unsigned int day = 0; day < numDays; day++ ) { for ( unsigned int hour = 0; hour < numHours; hour++ ) { appointments[day][hour] = rhs.appointments[day][hour]; } } return *this; } //------------------------------------------------------------------------- void TimeTable::addAppointment( int day, const Appointment& appointment ) { appointments[day][appointment.hour()] = appointment; } //------------------------------------------------------------------------- Appointment TimeTable::appointmentFor( int day, int hour ) const { return appointments[day][hour]; }