-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclosed_event.cpp
43 lines (39 loc) · 1.02 KB
/
closed_event.cpp
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
38
39
40
41
42
43
#include "closed_event.h"
using mtm::AlreadyInvited;
using mtm::ClosedEvent;
ClosedEvent::ClosedEvent(const mtm::DateWrap& date, const std::string& name)
:BaseEvent(date, name), invitees(){}
void ClosedEvent::addInvitee(int student)
{
if (student > this->MAX_STUDENT || student < this->MIN_STUDENT)
{
throw InvalidStudent();
}
if(invitees.contains(student))
{
throw AlreadyInvited();
}
invitees.add(student);
}
void ClosedEvent::registerParticipant(int participant)
{
if (participant > this->MAX_STUDENT || participant < this->MIN_STUDENT)
{
throw InvalidStudent();
}
if(invitees.contains(participant))
{
BaseEvent::registerParticipant(participant);
}
else
{
throw RegistrationBlocked();
}
}
ClosedEvent* ClosedEvent::clone() const
{
ClosedEvent* cloned_event = new ClosedEvent(this->date, this->name);
cloned_event->participants = this->participants;
cloned_event->invitees = this->invitees;
return cloned_event;
}