Question: need to make a Linked list between the teacher and the student. Thats all i need, if you guys help me with that i will
need to make a Linked list between the teacher and the student. Thats all i need, if you guys help me with that i will appericate it
WILL GIVE A THUMBS UP!!!
The files are down below
File:Teacher.h
#ifndef TEACHER_H #define TEACHER_H #define MAX_CLASS_SIZE 10 #include "student.h" #include "hwsubmissionexceptions.h" class Teacher { public: Teacher(); ~Teacher(); void deleteClass(); void intitalizeClass(); Student* getStudent(int i); string getAssignmentByName(string name); void assignGradeByName(string name,string grade); void addStudent(string name) throw(ClassFullException); //void addStudent(Student* pStudent) throw(ClassFullException); void save(char* fielName); void load(char* fileName); void print(); static void test(); private: int findStudentByName(string name) throw(StudentNotFoundException); int classSize; Student* pStudents[MAX_CLASS_SIZE]; //Implementas the aggregation relationship }; #endif // TEACHER_H
File:Teacher.cpp
#include "teacher.h" Teacher::Teacher() { classSize =0; for(int i;igetName() == name) return i; } throw StudentNotFoundException(); //return -1; } Student* Teacher::getStudent(int i){ return pStudents[i]; } string Teacher::getAssignmentByName(string name) { int found = findStudentByName(name); if(found>=0){ return pStudents[found]->getAssignment(); }else { cout<=0){ pStudents[found]->assignGrade(grade); }else { coutclassSize; in.getline(tmp,1); for(int i=0;iprint(); } } void Teacher::test(){ try{ Teacher aTeacher; aTeacher.intitalizeClass(); aTeacher.addStudent("Najam"); aTeacher.getStudent(0)->submitAssignment("Assignment of student 0"); aTeacher.getStudent(1)->submitAssignment("Assignment of student 1"); aTeacher.getStudent(2)->submitAssignment("Assignment of student 2"); aTeacher.print(); string student = "Najam"; cout<<"Trying to find "<=0) aTeacher.getStudent(found)->print(); // else cout<<"Could not find student"< FILE:STUDENT.H
#include
FILE:STUDENT.CPP
#include "student.h" Student::Student() { } Student::Student(string name){ this->name = name; } string Student::getName(){ return name; } void Student::setName(string name){ this->name = name; } void Student::submitAssignment(string assignment){ this->assignment= assignment; } string Student::getAssignment(){ return assignment; } void Student::assignGrade(string grade){ this->grade = grade; } string Student::getGrade(){ return grade; } /* void Student::save(char* fileName){ ofstream out(fileName); if(out.is_open()){ out << name< FILE:MAIN.CPP #include "student.h" #include "teacher.h" int main() { //cout<<"hello world "<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
