-
Notifications
You must be signed in to change notification settings - Fork 0
/
Session.cpp
70 lines (61 loc) · 1.19 KB
/
Session.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* File: Session.cpp
* Author: Kapil Thakkar
*
*/
#include <errno.h>
#include <vector>
#include "Session.h"
Session::Session()
{
papersInSession = 0;
}
Session::Session(int papersInSession)
{
this->papersInSession = papersInSession;
initPapers(papersInSession);
}
void Session::initPapers(int papersInSession)
{
this->papers = (int *)malloc(sizeof(int) * papersInSession);
for (int i = 0; i < papersInSession; i++)
{
papers[i] = -1;
}
}
int Session::getNumberOfPapers()
{
return papersInSession;
}
int Session::getPaper(int index)
{
if (index < papersInSession)
{
return papers[index];
}
else
{
cout << "Index out of bound - Session::getPaper" << endl;
exit(0);
}
}
void Session::setPaper(int index, int paperId)
{
if (index < papersInSession)
{
papers[index] = paperId;
}
else
{
cout << "Index out of bound - Session::setPaper" << endl;
exit(0);
}
}
void Session::printSession()
{
for (int i = 0; i < papersInSession; i++)
{
cout << papers[i] << " ";
}
cout << endl;
}