COSC 2010 / 2100 Data Structures

Fall 2018

Homework Assignment #6 : Help Desk Redux

Due: Friday, October 12th, 11:59pm CDT
Submit: Turn in your HelpDesk.java source file (and any other helper Java source files you devise) using the turnin command on morbius.mscs.mu.edu.
Work may be completed in teams of two.
Be certain to include both partner's names in your file. Try to avoid both partners submitting code -- we have to grade that twice, and only the lower grade will be kept.
You may submit multiple times, but only the last turnin will be kept. The automatic submission system will not accept work after the deadline.

Scandal at the HelpDesk!

Executive Director of the HelpDesk Service came under withering criticism from members of the Committee on Undergraduate Studies this week, as additional reports surfaced of turned-away students and unusually long wait times.

"My constituents are very, very concerned about these latest reports," stated the Committee chairperson, who then launched into a detailed criticism of existing HelpDesk Service policies. "Students are being turned away from the HelpDesk just because a classmate from the same course is already being helped, while other students from higher numbered courses just sit and wait."

"This is a totally stupid algorithm for running a HelpDesk Service," lamented another Committee member after the hearing. "You shouldn't be interrupting students already receiving help just because another student from a lower-numbered class shows up."

Similar reactions were elicited from department members unconnected to the HelpGate affair. As one UPE officer put it, "Why would you turn away students when there are plenty of chairs for them to wait in? Haven't these people heard of queues?"

Following the hearings, the HelpDesk Service announced that a comprehensive review of policies and procedures is underway, with a report on proposed changes due back to the Committee by Friday.

Help Desk Simulation with Queues

This assignment uses several Queues to simulate a HelpDesk for computer science students. You may use the textbook-inspired queue classes demonstrated in class, but not the built-in Java class library Queue interface and its implementing classes.

Unlike the previous HelpDesk policy, students will no longer be turned away when the HelpDesk is currently helping a student from a lower-numbered course. Instead, they will be directed to a waiting area with chairs. The waiting area is organized into four subdivisions -- one for the 1000-level courses, one for the 2000-level courses, one for the 3000-level courses, and one for the 4000-level courses. Each subdivision has three chairs for waiting students, and students in a subdivision will be helped in first-in, first-out order.

When a student arrives at the HelpDesk, if no one is currently being helped, and no one is in the waiting area, the student will be helped immediately. If someone is being helped, the student will be sent to the back of the line for the level of course in which they are seeking help.

When the current student being helped leaves, the HelpDesk will choose the next student from the 1000-level waiting area chairs to help first. If there are no students waiting in the 1000-level chairs, the first student in the 2000-level chairs will be helped, and so on.

If a student arrives and the waiting area for their level is full (all three chairs occupied), that student may be sent to the end of the waiting list for the next level up. Only if a student's waiting level is full, and all higher levels are also full, will a student be turned away.

The HelpDesk tutor still keeps track of who is coming and going, using a pile of notecards. When the shift is over, the notecards are read back and logged in first-to-last order. (The previous logs were in reverse order.)

Your HelpDesk class will be tested for the following API:

Input

Input to the HelpDesk simulator will consist of an initial line with a number of minutes for the simulation to run.

Each subsequent line of input will consist of an arrival time (in minutes), a name, a course number (we assume all courses are COSC, and therefore the letter code is not included,) and a workload time in minutes.

Input arrival times will occur strictly in order -- so each student's arrival will be strictly greater than or equal to the previous student's. You may assume that workload times will be strictly positive, non-zero integers.

Here are some example inputs and outputs.

Example Run #1

Ten minute simulation, three students arrive for help at non-overlapping times.
Input:
10
2 Jack 1010 2
5 Jill 1020 2
8 Robin 2010 1

Output:
Time 0, IDLE
Time 1, IDLE
Time 2, Helping Jack from COSC1010
Time 3, Helping Jack from COSC1010
Time 4, IDLE
Time 5, Helping Jill from COSC1020
Time 6, Helping Jill from COSC1020
Time 7, IDLE
Time 8, Helping Robin from COSC2010
Time 9, IDLE

LOG:
Time 2, Started helping Jack from COSC1010
Time 4, Finished helping Jack from COSC1010
Time 5, Started helping Jill from COSC1020
Time 7, Finished helping Jill from COSC1020
Time 8, Started helping Robin from COSC2010
Time 9, Finished helping Robin from COSC2010

Example Run #2

Twenty minute simulation, three students arrive for help at overlapping times in reverse priority order.
Input:
20
2 Robin 2010 8
5 Jill 1020 6
7 Jack 1010 2

Output:
Time 0, IDLE
Time 1, IDLE
Time 2, Helping Robin from COSC2010
Time 3, Helping Robin from COSC2010
Time 4, Helping Robin from COSC2010
Time 5, Helping Robin from COSC2010
Time 6, Helping Robin from COSC2010
Time 7, Helping Robin from COSC2010
Time 8, Helping Robin from COSC2010
Time 9, Helping Robin from COSC2010
Time 10, Helping Jill from COSC1020
Time 11, Helping Jill from COSC1020
Time 12, Helping Jill from COSC1020
Time 13, Helping Jill from COSC1020
Time 14, Helping Jill from COSC1020
Time 15, Helping Jill from COSC1020
Time 16, Helping Jack from COSC1010
Time 17, Helping Jack from COSC1010
Time 18, IDLE
Time 19, IDLE

LOG:
Time 2, Started helping Robin from COSC2010
Time 5, Queued Jill from COSC1020
Time 7, Queued Jack from COSC1010
Time 10, Finished helping Robin from COSC2010
Time 10, Started helping Jill from COSC1020
Time 16, Finished helping Jill from COSC1020
Time 16, Started helping Jack from COSC1010
Time 18, Finished helping Jack from COSC1010

Example Run #3

Twenty minute simulation, two students queued in waiting area.
Input:
20
2 Robin 2010 8
3 Jack 3100 2
4 Jill 1020 6

Output:
Time 0, IDLE
Time 1, IDLE
Time 2, Helping Robin from COSC2010
Time 3, Helping Robin from COSC2010
Time 4, Helping Robin from COSC2010
Time 5, Helping Robin from COSC2010
Time 6, Helping Robin from COSC2010
Time 7, Helping Robin from COSC2010
Time 8, Helping Robin from COSC2010
Time 9, Helping Robin from COSC2010
Time 10, Helping Jill from COSC1020
Time 11, Helping Jill from COSC1020
Time 12, Helping Jill from COSC1020
Time 13, Helping Jill from COSC1020
Time 14, Helping Jill from COSC1020
Time 15, Helping Jill from COSC1020
Time 16, Helping Jack from COSC3100
Time 17, Helping Jack from COSC3100
Time 18, IDLE
Time 19, IDLE

LOG:
Time 2, Started helping Robin from COSC2010
Time 3, Queued Jack from COSC3100
Time 4, Queued Jill from COSC1020
Time 10, Finished helping Robin from COSC2010
Time 10, Started helping Jill from COSC1020
Time 16, Finished helping Jill from COSC1020
Time 16, Started helping Jack from COSC3100
Time 18, Finished helping Jack from COSC3100

Example Run #4

Five students from same 4000-level course show up. Three are queued up, last one is turned away.
Input:
8
2 Jack 4300 1
2 Jill 4300 1
2 Robin 4300 1
2 Batman 4300 1
2 Joker 4300 1

Output:
Time 0, IDLE
Time 1, IDLE
Time 2, Helping Jack from COSC4300
Time 3, Helping Jill from COSC4300
Time 4, Helping Robin from COSC4300
Time 5, Helping Batman from COSC4300
Time 6, IDLE
Time 7, IDLE

LOG:
Time 2, Started helping Jack from COSC4300
Time 2, Queued Jill from COSC4300
Time 2, Queued Robin from COSC4300
Time 2, Queued Batman from COSC4300
Time 2, Turned away Joker from COSC4300
Time 3, Finished helping Jack from COSC4300
Time 3, Started helping Jill from COSC4300
Time 4, Finished helping Jill from COSC4300
Time 4, Started helping Robin from COSC4300
Time 5, Finished helping Robin from COSC4300
Time 5, Started helping Batman from COSC4300
Time 6, Finished helping Batman from COSC4300

[Revised 2018 Oct 08 10:43 DWB]