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
|
void Combine(string x,string y,string z)
{
int flag=0; string a,b,c,d,e,f,g,h;
for(int i=0; i<lecturer.size();i++) // Fetch lecturer's faculty
if(Upper(lecturer[i].getLecName())==Upper(x))
{
a = lecturer[i].getLecName();
b = lecturer[i].getLecId();
c = lecturer[i].getLecFac();
}
for(int i=0; i<student.size();i++) // Fetch student's faculty
if(Upper(student[i].getStudName())==Upper(y))
{
d = student[i].getStudName();
e = student[i].getStudId();
f = student[i].getStudFac();
}
for(int i=0; i<project.size();i++) // Fetch project's faculty
if(Upper(project[i].getProjName())==Upper(z))
{
g = project[i].getProjName();
h = project[i].getProjId();
}
Record temp(a,b,c,d,e,f,g,h); // Confirm registration
record.push_back(temp);
}
void Import(char filename[])
{
vector<string>temp;
ifstream in; string data;
in.open(filename);
while (getline(in,data,'\n')) // Store the data line by line
temp.push_back(data);
for (int i=0; i<temp.size(); i++)
{
int count=0; string str = temp[i];
stringstream stream(str);
while(getline(stream, data, ',')) // Seperate data by comma
{
if(count==0)
temp1 = data;
else if (count==1)
temp2 = data;
count++;
}
if(filename=="lecturer.txt")
{
Lecturer x(temp1, temp2, temp3);
lecturer.push_back(x);
Combine("", temp1);
}
else if(filename=="students.txt")
{
Student x(temp1, temp2, temp3);
student.push_back(x);
Combine(temp1,"");
}
else if(filename=="projects.txt")
Combine(temp1,temp2,temp3);
}
temp.clear();
in.clear();
in.close();
}
string Upper(string x)
{
for (int i=0; i<x.size(); i++)
x[i] = toupper(x[i]);
return x;
}
|