#ifndef COURSES_H
#define COURSES_H
class Courses
{
private:
struct CourseList
{
char courseNum[10];
char courseName[25];
char courseSch[20];
CourseList *next;
};
CourseList *head;
void displayArrayChar(char [], int);
public:
Courses(void)
{head=NULL;}
~Courses(void);
void appendCourse(char [],char [], char []);
void appendCourse(CourseList *);
void deleteCourse(char []);
bool searchforCourse(char []);
void displayAllCourses(void);
void editCourses(char [], char [], int );
void emptyCourses(void); //function called when a student is deleted
CourseList* getHead(void){return head;}
//friend void StudentInfo::insertStudent(char [], char [], int [], CourseList *);
};
#endif
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//studentinfo.h
#ifndef STUDENTINFO_H
#define STUDENTINFO_H
#include
#include \"Courses.h\"
using namespace std;
class StudentInfo
{
private:
struct StudentList
{
char firstName[12];
char lastName[12];
int ssn[9];
Courses studentCourses;
struct StudentList *next;
};
StudentList *ssnhead;
int tempStoreSSN[9];
void displayArrayChar(char [], int);
void displayArrayInt(int []);
bool testIntArray(int [], int []);
public:
StudentInfo(void)
{ssnhead=NULL;}
~StudentInfo(void);
void insertStudent(char [], char [], int [], Courses &);
void insertStudent(char fn[], char ln[], int s[]);
void deleteStudent(int []);
bool searchBylast(char []);
bool searchByssn(int []);
void displayAllStudents(void);
void editStudentInfo(int []);
void editStudentInfo(char [],int);
int getTempssn(int);
void storessnTemp(char [], int);
};
#endif
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//courses.cpp
#include
#include
#include
#include \"courses.h\"
#include \"studentinfo.h\"
using namespace std;
Courses::~Courses(void)
{
CourseList *nodePtr, *nextNode;
nodePtr=head;
while (nodePtr !=NULL)
{
nextNode=nodePtr->next;
delete nodePtr;
nodePtr=nextNode;
}
head=NULL;
}
void Courses::appendCourse(CourseList *tempHead) //should only pass the head pointer of the
node
{
CourseList *nodePtr, *nodeTempPtr, *newNode;
nodePtr=head;
nodeTempPtr=nodePtr;
while(nodeTempPtr->next !=NULL)
{nodePtr=nodePtr->next;
}
nodeTempPtr = tempHead;
while(nodeTempPtr->next !=NULL)
{
newNode=new CourseList;
strcpy(newNode->courseNum, nodeTempPtr->courseNum);
strcpy(newNode->courseName, nodeTempPtr->courseName);
strcpy(newNode->courseSch, nodeTempPtr->courseSch);
newNode->next=NULL;
nodePtr->next=newNode;
nodePtr=nodePtr->next;
nodeTempPtr=nodeTempPtr->next;
}
}
void Courses::appendCourse(char cNum[], char cName[], char cSch[])
{
CourseList *newNode, *nodePtr;
newNode=new CourseList;
strcpy(newNode->courseNum, cNum);
strcpy(newNode->courseName, cName);
strcpy(newNode->courseSch, cSch);
newNode->next=NULL;
if(!head)
head=newNode;
else
{
nodePtr=head;
while(nodePtr->next)
{
nodePtr=nodePtr->next;
}
nodePtr->next=newNode;
}
}
void Courses::emptyCourses(void)
{
CourseList *nodePtr, *nextNode;
nodePtr=head;
while (nodePtr !=NULL)
{
nextNode=nodePtr->next;
delete nodePtr;
nodePtr=nextNode;
}
head=NULL;
}
void Co.