-
Notifications
You must be signed in to change notification settings - Fork 0
/
Conference.cpp
103 lines (92 loc) · 2.38 KB
/
Conference.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* File: Conference.cpp
* Author: Kapil Thakkar
*
*/
#include "Conference.h"
Conference::Conference()
{
this->parallelTracks = 0;
this->sessionsInTrack = 0;
this->papersInSession = 0;
}
Conference::Conference(int parallelTracks, int sessionsInTrack, int papersInSession)
{
this->parallelTracks = parallelTracks;
this->sessionsInTrack = sessionsInTrack;
this->papersInSession = papersInSession;
initTracks(parallelTracks, sessionsInTrack, papersInSession);
}
void Conference::initTracks(int parallelTracks, int sessionsInTrack, int papersInSession)
{
tracks = (Track *)malloc(sizeof(Track) * parallelTracks);
for (int i = 0; i < parallelTracks; i++)
{
Track tempTrack(sessionsInTrack);
for (int j = 0; j < sessionsInTrack; j++)
{
Session tempSession(papersInSession);
tempTrack.setSession(j, tempSession);
}
tracks[i] = tempTrack;
}
}
int Conference::getParallelTracks()
{
return parallelTracks;
}
int Conference::getSessionsInTrack()
{
return sessionsInTrack;
}
int Conference::getPapersInSession()
{
return papersInSession;
}
Track Conference::getTrack(int index)
{
if (index < parallelTracks)
{
return tracks[index];
}
else
{
cout << "Index out of bound - Conference::getTrack" << endl;
exit(0);
}
}
void Conference::setPaper(int trackIndex, int sessionIndex, int paperIndex, int paperId)
{
if (this->parallelTracks > trackIndex)
{
Track curTrack = tracks[trackIndex];
curTrack.setPaper(sessionIndex, paperIndex, paperId);
}
else
{
cout << "Index out of bound - Conference::setPaper" << endl;
exit(0);
}
}
void Conference::printConference(char *filename)
{
ofstream ofile(filename);
for (int i = 0; i < sessionsInTrack; i++)
{
for (int j = 0; j < parallelTracks; j++)
{
for (int k = 0; k < papersInSession; k++)
{
ofile << tracks[j].getSession(i).getPaper(k) << " ";
}
if (j != parallelTracks - 1)
{
ofile << "| ";
}
}
ofile << "\n";
}
ofile.close();
// cout << "Organization written to ";
// printf("%s :)\n", filename);
}