Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "studentlist.h"
- using namespace std;
- //*****INDEX*****
- //Student Class
- //StudentList Class
- //History Class
- //Math Class
- //English Class
- //**************************Student Class*********************************//
- Student::Student(){
- firstName[0] = '\n';
- lastName[0] = '\n';
- classType = " ";
- }
- Student::Student(const char* fn, const char* ln, const string& c){
- strcpy(firstName,fn);
- strcpy(lastName,ln);
- classType = c;
- }
- const char* Student::getFN(){return this->firstName;}
- const char* Student::getLN(){return this->lastName;}
- const string Student::getCT(){return this->classType;}
- //**************************StudentList Class*********************************//
- StudentList::StudentList(){
- size = 0;
- tracker = 0;
- list = new Student*[size];
- }
- StudentList::~StudentList(){
- for(int i = 0; i <= size; i++)
- delete list[i];
- delete[] list;
- }
- bool StudentList::ImportFile(const char* filename){
- bool check = false;
- Student s;
- ifstream in;
- if(check == false){
- in.open(filename);
- if(!in){
- cout << "File input error\nTry again" << endl;
- return false;
- }
- check = true;
- }
- int sSize;
- char last[20];char first[20];
- string c;
- in >> sSize;
- for(int i = 0; i < sSize; i++){
- in.getline(last,20,',');
- in.getline(first,20,'\n');
- in >> c;
- if(c == "Math"){
- int tq1,tq2,tq3,tq4,tq5,tt1,tt2,ttf;
- in >> tq1;in >> tq2;
- in >> tq3;in >> tq4;
- in >> tq5;in >> tt1;
- in >> tt2;in >> ttf;
- cout << "made it to math" << endl;
- list[tracker] = new Math(first,last,c,tq1,tq2,tq3,tq4,tq5,tt1,tt2,ttf);
- Grow();
- }
- else if(c == "English"){
- int ta,tp,tm,tf;
- in >> ta;in >> tp;
- in >> tm;in >> tf;
- cout << "made it to english" << endl;
- list[tracker] = new English(first,last,c,ta,tp,tm,tf);
- Grow();
- }
- else if(c == "History"){
- int tp,tm,tf;
- in >> tp;in >> tm;in >> tf;
- cout << "made it to history" << endl;
- list[tracker] = new History(first,last,c,tp,tm,tf);
- Grow();
- }
- else
- return false;
- }
- return true;
- }
- bool StudentList::CreateReportFile(const char* filename){
- /*
- ofstream o;
- o << "Student Grade Summary\n"
- << "---------------------\n\n";
- o << "ENGLISH CLASS\n\n";
- o << "Student Final Final Letter\n";
- o << "Name Exam Avg Grade\n";
- o << "----------------------------------------------------------------------\n";
- for(int i = 0; i < tracker;i++){
- if(list[i]->classType == "English"){
- o << list[i]->firstName << " " << list[i]->lastName << setw(20) << left << list[i]->Final << " " << list[i]->getAvg() << " ";
- }
- }
- */return true;
- }
- void StudentList::ShowList() const {
- cout << "Last First Course\n\n";
- for(int i = 0; i <= 1; i++){
- cout << setw(20) << left << list[i]->getLN() << setw(20) << left << list[i]->getFN() << setw(20) << left << list[i]->getCT();
- }
- }
- void StudentList::Grow(){
- if(tracker == size){
- Student* * TL = new Student*[size + 3];
- cout << "size is = " << size << endl;
- cout << "new size is = " << size + 3 << endl;
- cout << "tracker is = " << tracker << endl;
- for(int i = 0; i <= tracker; i++){
- TL[i] = list[i];
- cout << "no seg fault at: " << i << endl;
- }
- cout << "temp list is filled" << endl;
- for(int i = 0; i <= size; i++){
- delete list[i];
- cout << "no seg fault at: " << i << endl;
- }
- delete[] list;
- list = new Student*[size + 3];
- list = TL;
- cout << "list transfer complete" << endl;
- size = size + 3;tracker++;
- delete[] TL;
- cout << "made it thru grow" << endl;
- }
- }
- //const int StudentList::getSize(){return size;}
- //const int StudentList::getTracker(){return tracker;}
- //int StudentList::setTracker(int p){return tracker += p};
- //**************************History Class*********************************//
- History::History(const char* fn, const char* ln,const string& c,const int& p, const int& m, const int& f) : Student(fn,ln,c){
- paper = p;
- midterm = m;
- Final = f;
- }
- /*
- const int History::getAttend(){return attend;}
- const int History::getProject(){return project;}
- const int History::getMidterm(){return midterm;}
- const int History::getFinal(){return Final;}
- */
- double History::getAvg(){
- avg = (.25 * paper) + (.35 * midterm) + (.40 * Final);
- return avg;
- }
- //**************************Math Class*********************************//
- Math::Math(const char* fn,const char* ln,const string& c,const int& qq1, const int& qq2, const int& qq3, const int& qq4, const int& qq5, const int& t1, const int& t2, const int& tf) : Student(fn,ln,c){
- q1 = qq1;
- q2 = qq2;
- q3 = qq3;
- q4 = qq4;
- q5 = qq5;
- test1 = t1;
- test2 = t2;
- testF = tf;
- }
- double Math::getAvg(){
- avg = (.15 * (q1+q2+q3+q4+q5)) + (.25 * test1) + (.25 * test2) + (.35 * testF);
- return avg;
- }
- //**************************English Class*********************************//
- English::English(const char* fn,const char* ln,const string& c,const int& a,const int& p, const int& m, const int& f) : Student(fn,ln,c){
- attend = a;
- project = p;
- midterm = m;
- Final = f;
- }
- double English::getAvg(){
- avg = (.10 * attend) + (.30 * project) + (.30 * midterm) + (.30 * Final);
- return avg;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement