-
Notifications
You must be signed in to change notification settings - Fork 0
/
recurring_event.h
37 lines (35 loc) · 986 Bytes
/
recurring_event.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef RECURRING_EVENT_H_
#define RECURRING_EVENT_H_
#include "event_container.h"
#include "date_wrap.h"
#include "exceptions.h"
namespace mtm
{
template <typename EventType>
class RecurringEvent : public EventContainer
{
public:
RecurringEvent(const DateWrap& date, const std::string& name, int num_occurrences, int interval_days)
:EventContainer()
{
if(num_occurrences <=0)
{
throw InvalidNumber();
}
if(interval_days <= 0)
{
throw InvalidInterval();
}
EventType event(date, name); //NOTE: THIS MEANS WE DON'T SUPPORT CUSTOM EVENT
for(int i = 0; i < num_occurrences; i++)
{
EventContainer::add(event);
event.changeDate(interval_days);
}
}
void add(const BaseEvent& event) override{
throw NotSupported();
}
};
}
#endif