Programming Project #1
Due 9/14
For this assignment you will
create a data structure for maintaining a list of students from different
universities. The structure will consist
of a single master linked list, specified below. Each node of the master list will have two
data fields. The first is simply a
string denoting a univeristy such as "utpa". The second field is of type subLL, which is a
second type of linked list you will create, specified below. So, the data structure is a master linked
list such that each node contains its own sublist. Each sublist will contain the list of all
students in the data structure that attend the same university.
To complete this assignment,
implement the functions specified below.
In particular, when a new student is inserted into the masterLL, the
student should be instered into the correct sub list according the the
student's university. If no such
university exists yet, a new node must be added to the masterLL. In addition, implement the function specified
below that, given a university, will list all the students which attend that
university.
#include <iostream>
#include <string>
using namespace std;
class student
{
public:
string name;
string university;
};
//the sub linked
list type. A subLL is simply a linked
list of students.
//For this
problem, each subLL should only contain students that attend the same
//university.
class subLL
{
private:
class node
{
public:
student data;
node * next;
};
node * head;
public:
subLL();
//insert student s into the linked
list
void add(student s);
//cout all students in the list.
void displayAll();
};
//The master
linked list type. Each node in a
masterLL has a data field
//containing a
subLL holding all students from a given university. The exact
//univeristy
that is represented by the subLL should be specified by the university field
//of each node.
class masterLL
{
private:
class node
{
public:
string university;
subLL students;
node * next;
};
node * head;
public:
masterLL();
//add a new student to the data
structure.
//The student must be inserted into
the sublist that corresponds to
//the students university. If no such university exists in the master
list,
//a new node must be added to the
master list and the student should be inserted
//into the new sublist.
void addStudent(student s);
//list all students from the
university univ.
void
listStudentsFromUniversity(string univ);
};