The priority can be obtained from the order in which the time slots are listed in the file. For this lab a new schedule file called "schedule2" has been placed in the course folder. For example, if the file contained the following line:
Eric 8 4 10 3
It can be interpreted as meaning that my first preference is time slot 8, my second is for time slot 4, etc.
Your first step should be to rewrite your old program to include this
information. Be sure to update display() and draw such that they now
displays priority information. Your second step should be to further
update your old program such that the insert routine inserts by priority
rather than simply at the front or end of the list. That is to say
that the list should be maintained in such a way that all of the students
who have the time slot as their first priority are at the start of the
list, followed by all of the students for whom the time slot is the second
priority, etc.
for each level of priority
for each time slot
if only one student has the time slot at the current level of priority
then {
the student is given the time slot - an appropriate message is printed
the time slot is removed from future consideration
all occurences of the student are removed from other time slots
}
else all students with the current priority are removed from this time
slot
To implement this algorithm you will need one more function in your
StringList class - delete(String s) - which should search for a
Node with the appropriate value and delete it from the StringList.
A function howmany(int n) which returns the number of strings at
priority level n will also be useful. Implement the algorithm and
run it on the "schedules2" file. With such a function, another version
of delete - delete(int n) which deletes the first n elements
of the StringList - might also be useful. While you are debugging the
program, I highly reccommend you make liberal use of your display and
draw functions. E.g. when you are debugging the new delete function,
immediately display the list to ensure that the delete worked properly.
Also, hand in hardcopy listings of these program files with your name on them and a hardcopy version of your program's output on the schedule2 file. Your program should contain sufficient commentary documentation for me to understand its overall design and logic. Include with this, your answers to the questions in Part 2.