/**************************************************************** PROGRAM: Project 1 AUTHOR: Anthony Hogan LOGON ID: Z109079 DUE DATE: 1/26/2009 FUNCTION: creates a program that enables a user to input student data. Including name, zid, SSN, and courses. INPUT: from keyboard OUTPUT: A list of all courses taken/schedules for a certain student. NOTES: Uses 6 files. Student.h, Student.cpp, Person.h, Person.cpp, courseInfo.h, courseInfo.cpp, and 340.h. ****************************************************************/ #include "Person.h" #include "CourseInfo.h" #include "Student.h" #include #include #include #include #include using namespace std; int main() { //create Student object and declare variables to be used in creating student Student s1; bool empty; string file; fstream inFile; //test if list is empty before data is filled cout << endl << "Test 1, Check if list is empty:" << endl; empty = s1.courseList.isEmpty(); cout << "Empty = " << empty; if(empty == true) cout << "Student Object is empty" << endl; else cout << "Student Object is not empty" << endl; //read data from file and fill the list with courses inFile.open("C:\\Documents and Settings\\Tony\\My Documents\\Visual Studio 2008\\Projects\\proj1\\file.txt"); if(!inFile) { cout << "Can't open file , program terminated." << endl; return 0; } s1.loadInfoFromFile(inFile); inFile.close(); cout << endl << "Test 2, Check if list was filled:" << endl; s1.infoPrint(); //check if list is empty after data has been filled cout << endl << "Test 3, Check if list is empty:" << endl; empty = s1.courseList.isEmpty(); if(empty == true) cout << "Student Object is empty" << endl; else cout << "Student Object is not empty" << endl; //check to see if you can successfully add a course to the list cout << endl << "*** ADD A COURSE TO THE STUDENT ***" << endl << endl; CourseInfo c1; string id1, yt1, st1, so1; cout << "Enter course id to add: "; cin >> id1; c1.setCourseID(id1); cout << "Enter year the course was taken: "; cin >> yt1; c1.setYearTaken(yt1); cout << "Enter semester the course was taken: "; cin >> st1; c1.setSemesterTaken(st1); cout << "Enter grade earned in the course: "; cin >> so1; c1.setGrade(so1); s1.addCourse(s1.getZID(), c1); cout << endl << "Test 4, check if course was added:" << endl; s1.infoPrint(); /* //check to see if you can remove a course from the list cout << endl << "*** REMOVE A COURSE FROM A STUDENT ***" << endl << endl; CourseInfo c2; string id2, yt2, st2, so2; cout << "Enter course id to remove: "; cin >> id2; c2.setCourseId(id2); cout << "Enter year the course was taken: "; cin >> yt2; c2.setYearToTake(yt2); cout << "Enter semester the course was taken: "; cin >> st2; c2.setSemesterToTake(st2); s1.deleteCourse(s1.getZid(), c2); cout << endl << "Test 5, check if course was removed:" << endl; s1.infoPrint(); //check if a certain course exists in the list cout << endl << "*** CHECK IF A STUDENT HAS TAKEN A COURSE ***" << endl << endl; CourseInfo c3, c4; string id3; cout << "Enter the course id to be checked: "; cin >> id3; c3.setCourseId(id3); c4 = s1.checkCourseTaken(s1.getZid(), c3); cout << endl << "Test 6, check if course was taken:" << endl; if(c4.getCourseId() == "") cout << endl << "*** COURSE NOT TAKEN ***" << endl << endl; else cout << endl << "Student took " << c4.getCourseId() << " in the " << c4.getSemesterToTake() << " of " << c4.getYearToTake() << " and earned a grade of " << c4.getScoreObtained() << "." << endl << endl; cout << "*** END OF PROGRAM OUTPUT ***" << endl; */ return 0; }//end main