Hi all,
I recently finished working on a project that was to create a database type system for a student registration system. I created my own list class and stack to store the data... i create multiple classes, person (store student data: name, ssn, etc), student (student ID number), courseInfo (class name, grade, semester, year).
I now have to be able to read in from file (just like before) but this time i need to read in multiple students. As follows:
John Smith 333222333 01/01/89 M z11119
CSCI340 2008 Fall A
CSCI231 2008 Fall B
Linda Ray 333222333 01/01/88 M z11203
CSCI340 2008 Fall B
CSCI201 2008 Fall B
Rene Hanson 333222333 01/01/81 M z22003
CSCI340 2007 Fall A
CSCI210 2008 Spring B
First off, i am going to use a marker in the file above, such as a '$' to denote end of a student data... therefore when i do the read in, and i hit '$' i know that is the end of the that students data.
My problem arises in trying to figure out how i can read in multiple students. As of now i do the following:
void Student::loadInfoFromFile(fstream& inFile)
{
string firstName, lastName, SSN, DOB, gender,
ZID, courseID, year, semester, grade;
inFile >> firstName;
setFirstName(firstName);
inFile >> lastName;
setLastName(lastName);
inFile >> SSN;
setSSN(SSN);
inFile >> DOB;
setDOB(DOB);
inFile >> gender;
setGender(gender);
inFile >> ZID;
setZID(ZID);
//start class read
inFile >> courseID;
while (inFile)
{
inFile >> year;
inFile >> semester;
inFile >> grade;
CourseInfo courses;
courses.setCourseID(courseID);
courses.setYearTaken(year);
courses.setSemesterTaken(semester);
courses.setGrade(grade);
addCourse(getZID(), courses);
inFile >> courseID;
//check for courseID == '$' ????
}
That is how i read in from file and it works flawlessly for one student. How then, can i edit this to work with multiple students. I ask this because how would i set up my data type? Do i create a list that contains each student per node? So i read in student one....fill in that persons student info, and class list, then store that in the first node of a linked list. Then read in the second student, ...then store as second node in my linked list?
If this is a way it could be done, could someone give me some psuedo code, because right now i am at a complete loss.
Thank you