This assignment uses several Stacks to simulate a HelpDesk for computer science students. Use the Stack Demonstration Code from class to implement your solution.
The DSLinkedStack class bears close resemblance to the Stack classes in Chapter 3 of your textbook, and has the following API:
Note that this is a generic Java data structure, and can be instantiated with any Java class in place of type "T".
Your task is to simulate a Help Desk for computer science students seeking assistance with their homework. This rudimentary Help Desk will only be able to help one student at a time, although others may sit in a nearby stack of chairs while they wait.
Because the Help Desk is aimed primarily at helping students in the introductory classes, a draconian priority policy has been set in place: If a student arrives at the help desk from a lower numbered course than the student who is currently being helped, the current student will be moved to the stack of waiting chairs until the new student has been helped. If a student arrives from a higher (or equal) course than the student currently being helped, the new student will be turned away.
The HelpDesk tutor also 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 reverse order.
Your HelpDesk class will be tested for the following API:
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. If only students arrived at the Help Desk in the real world labeled with precisely how many minutes it would take to help them...
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.
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 9, Finished helping Robin from COSC2010
Time 8, Started helping Robin from COSC2010
Time 7, Finished helping Jill from COSC1020
Time 5, Started helping Jill from COSC1020
Time 4, Finished helping Jack from COSC1010
Time 2, Started helping Jack from COSC1010
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 Jill from COSC1020
Time 6, Helping Jill from COSC1020
Time 7, Helping Jack from COSC1010
Time 8, Helping Jack from COSC1010
Time 9, Helping Jill from COSC1020
Time 10, Helping Jill from COSC1020
Time 11, Helping Jill from COSC1020
Time 12, Helping Jill from COSC1020
Time 13, Helping Robin from COSC2010
Time 14, Helping Robin from COSC2010
Time 15, Helping Robin from COSC2010
Time 16, Helping Robin from COSC2010
Time 17, Helping Robin from COSC2010
Time 18, IDLE
Time 19, IDLE
LOG:
Time 18, Finished helping Robin from COSC2010
Time 13, Finished helping Jill from COSC1020
Time 9, Finished helping Jack from COSC1010
Time 7, Started helping Jack from COSC1010
Time 5, Started helping Jill from COSC1020
Time 2, Started helping Robin from COSC2010
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 Jill from COSC1020
Time 6, Helping Jill from COSC1020
Time 7, Helping Jill from COSC1020
Time 8, Helping Jill from COSC1020
Time 9, Helping Jill from COSC1020
Time 10, Helping Jill from COSC1020
Time 11, Helping Robin from COSC2010
Time 12, Helping Robin from COSC2010
Time 13, Helping Robin from COSC2010
Time 14, Helping Robin from COSC2010
Time 15, Helping Robin from COSC2010
Time 16, IDLE
Time 17, IDLE
Time 18, IDLE
Time 19, IDLE
LOG:
Time 16, Finished helping Robin from COSC2010
Time 11, Finished helping Jill from COSC1020
Time 7, Turned away Jack from COSC3100
Time 5, Started helping Jill from COSC1020
Time 2, Started helping Robin from COSC2010
For your convenience, we provide the HelpDeskRunner.java file we are using for parsing input and running the simulation.
[Revised 2014 Sep 15 22:22 DWB]