-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.cpp
More file actions
163 lines (150 loc) · 6.18 KB
/
info.cpp
File metadata and controls
163 lines (150 loc) · 6.18 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include "info.hpp"
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
Person_info::Person_info()
: first_name("N/A"), last_name("N/A"), email("N/A"), institution("N/A") {}//deafaults for person info
void Person_info::setFirstName(string fn) { first_name = fn; }
void Person_info::setLastName(string ln) { last_name = ln; }
void Person_info::setEmail(string el) { email = el; }
void Person_info::setInstitution(string in) { institution = in; }
string Person_info::getFirstName() { return first_name; }
string Person_info::getLastName() { return last_name; }
string Person_info::getEmail() { return email; }
string Person_info::getInstitution() { return institution; }
Presentation_info::Presentation_info()//defaults for presentation info
: presentation_name("N/A"), room_name("N/A"), day("N/A"),
description("N/A"), startHour(0), startMin(0), endHour(0), endMin(0) {}
void Presentation_info::setPresentationName(string pn) { presentation_name = pn; }
void Presentation_info::setRoomName(string rn) { room_name = rn; }
void Presentation_info::setDay(string da) { day = da; }
void Presentation_info::setDescription(string de) { description = de; }
void Presentation_info::setStartHour(int sh) {startHour = sh;}
void Presentation_info::setStartMin(int sm) {startMin = sm;}
void Presentation_info::setEndHour(int eh) {endHour = eh;}
void Presentation_info::setEndMin(int em) {endMin = em;}
string Presentation_info::getPresentationName() { return presentation_name; }
string Presentation_info::getRoomName() { return room_name; }
string Presentation_info::getDay() { return day; }
string Presentation_info::getDescription() { return description; }
int Presentation_info::getStartHour() {return startHour;}
int Presentation_info::getStartMin() {return startMin;}
int Presentation_info::getEndHour() {return endHour;}
int Presentation_info::getEndMin() {return endMin;}
void Presentation_info::addPerson(Person_info temp) {
presenters.push_back(temp);//used when reading from file to get multiple people
}
void Presentation_info::setDataInfo(ifstream &infile, string line) {//reading from txt file
if (line.find("Name: ") != string::npos) {
presentation_name = line.substr(6);
}
if (line.find("Day: ") != string::npos) {
day = line.substr(5);
}
if (line.find("Time: ") != string::npos) {//gets time by seperating hours and mins from file
string time = line.substr(6);
for(int i = 0; i < time.length();i++){
if(time[i] == ':'){
if(startHour == 0)
startHour = stoi(time.substr(0,i));
else
endHour = stoi(time.substr(0,i));
if(startMin == 0)
startMin = stoi(time.substr(i+1, time.find('m')-(i+2)));
else
endMin = stoi(time.substr(i+1, time.find('m')-(i+2)));
}
if(time[i] == '-'){
time = time.substr(i+2);
i = 0;
}
}
}
if (line.find("Room: ") != string::npos) {
room_name = line.substr(6);
}
if (line.find("Presenters: ") != string::npos) {//gets presentors first and last name and seperates individuals by ','
Person_info tempPerson; // temp object
string str = line.substr(12);
for (int i = 0; i < str.length(); i++) {
if (str[i] == ' ') {
string s(str, 0, i);
tempPerson.setFirstName(s);
tempPerson.setLastName(str.substr(i + 1, str.find(',') - (i + 1)));
}
if (str[i] == ',') {
str = str.substr(i + 2);
addPerson(tempPerson);
i = 0;
}
}
addPerson(tempPerson);
}
if (line.find("Emails: ") != string::npos) {//seperates emails by individual by ','
string str = line.substr(8);
int count = 1;
this->presenters[0].setEmail(str.substr(0, str.find(',')));
for (int i = 0; i < str.length(); i++) {
if (str[i] == ',') {
str = str.substr(i + 2);
this->presenters[count].setEmail(str.substr(0, str.find(',')));
count++;
i = 0;
}
}
}
if (line.find("Institution: ") != string::npos) {//seperates school by individual by ','
for (int i = 0; i < this->presenters.size(); i++) {
this->presenters[i].setInstitution(line.substr(13));
}
}
if (line.find("Description: ") != string::npos) {
description = line.substr(13);
}
if (line.find("Track: ") != string::npos) {
presentation_type = line.substr(7);
}
}
void Presentation_info::printPresentationData() {//used when displaying presentation in schedule or in search
cout << "Title: " << presentation_name << endl
<< "Type: " << presentation_type << endl
<< "Day & Time: " << day << " " << startHour << ":" << startMin << " - " << endHour << ":" << endMin << endl
<< "Room: " << room_name << endl
<< "Institution: " << this->presenters[0].getInstitution() << endl;
for (int i = 0; i < this->presenters.size(); i++) {
cout << "Presenter " << i + 1 << ": " << this->presenters[i].getFirstName()
<< " " << this->presenters[i].getLastName() << endl;
cout << "Email: " << this->presenters[i].getEmail() << endl;
}
cout << endl << "Description: " << endl;
const int LINE_WIDTH = 80;
istringstream iss(description);
string word, l;
while (iss >> word) {
if (l.size() + word.size() + 1 <= LINE_WIDTH) {
l += (l.empty() ? "" : " ") + word;
} else {
cout << l << endl;
l = word;
}
}
cout << l << endl;
cout << "--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------" << endl << endl;
}
void Presentation_info::emailList() {//all emails
for (int i = 0; i < this->presenters.size()-1; i++) {
cout << this->presenters[i].getEmail() << ", ";
}
cout << this->presenters[this->presenters.size()-1].getEmail();
}
void Presentation_info::searchName(string fn, string ln, bool &in_list){//to search for presentor and their presentations
for (int i = 0; i < this->presenters.size(); i++) {
if(fn == presenters[i].getFirstName() && ln == presenters[i].getLastName()){
in_list = true;
printPresentationData();
}
}
}