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
|
#include "roster.h"
#include "Student.h"
using std::cout;
using std::cerr;
Roster::Roster()
{
this->capacity = 0;
this->lastIndex = -1;
this->student = nullptr;
}
Roster::Roster(int capacity)
{
this->capacity = capacity;
this->lastIndex = -1;
this->student = new Student*[capacity];
}
Student* Roster::getStudentat(int index)
{
return student[index];
}
void Roster::parseThenAdd(string row)
{
if (lastIndex < capacity) {
lastIndex++;
DegreeType DegreeType;
if (DegreeType == "SECURITY") { DegreeType = SECURITY;} // here is the code that is giving me the error
else if (DegreeType == "NETWORKING") { DegreeType = NETWORK;}
else if (DegreeType == "SOFTWARE") { DegreeType = SOFTWARE;}
{
cerr << "INVALID DEGREE TYPE! EXITING NOW!\n";
exit(-1);
}
int rhs = row.find(",");
string sID = row.substr(0, rhs);
int lhs = rhs + 1;
rhs = row.find(",", lhs);
string fName = row.substr(lhs, rhs - lhs);
int lhs = rhs + 1;
rhs = row.find(",", lhs);
string lName = row.substr(lhs, rhs - lhs);
int lhs = rhs + 1;
rhs = row.find(",", lhs);
string eAddress = row.substr(lhs, rhs - lhs);
int lhs = rhs + 1;
rhs = row.find(",", lhs);
string age = row.substr(lhs, rhs - lhs);
int lhs = rhs + 1;
rhs = row.find(",", lhs);
int daysInCourse1 = row.substr(lhs, rhs - lhs);
int lhs = rhs + 1;
rhs = row.find(",", lhs);
int daysInCourse2 = row.substr(lhs, rhs - lhs);
int lhs = rhs + 1;
rhs = row.find(",", lhs);
int daysInCourse3 = row.substr(lhs, rhs - lhs);
add(sID, fName, lName, eAddress, age, daysInCourse1, daysInCourse2, daysInCourse3, DegreeType);
}
else {
cerr << "ERROR! LIST LAS EXCEEDED MAXIMUM CAPACITY!\n EXITING NOW!";
exit(-1);
}
}
|