COSC 2010 / 2100 Data Structures

Fall 2018

Homework Assignment #3 : Help Desk, Help Thyself

Due: Wednesday, September 19th, 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.
Do not turnin the HelpDeskRunner class, or any of the Stack Demonstration Code. These files will be ignored by TA-bot.
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.

Stacks

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 2 of your textbook (3rd edition; chapter 3 in the 2nd edition), 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".

Help Desk Simulation

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

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.

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 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

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 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

Example Run #3

Twenty minute simulation, third student is turned away.
Input:
20
2 Robin 2010 8
5 Jill 1020 6
7 Jack 3100 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 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 2018 Sep 14 10:35 DWB]