The management at INITECH corporation is cleaning house and wants to simulate the work of its office personnel to provide a productivity threshold to measure existing employees. You are to write the simulation for the clerk who processes maintenance requests at INITECHs corporate headquarters.
Requests for service are sent as a form to the processing clerk to be prioritized, validated, and approved before being sent off to be fulfilled. You are to write a program to simulate forms processing by an office clerk. For the simulation, individual form information, called a Request, is obtained from an input file.
For implementation purposes, each Request has a ID number, execution time required to process the request (this includes the time needed to obtain approval to fulfill the service requests from senior officials in the company), an entry time (This is the time the request was made. Note that it must be later than all requests with a lower ID number), a priority (from 1 to 4 where 1 is the highest priority), and a description of the service being requested. see image.
When a request is first read from the input file, it will be handled immediately if the clerk is free. Otherwise, it will be placed in the input priority queue. Requests are not processed completely all at once because the clerk wants to distribute his attention fairly. The clerk works on a request for a fixed unit of time (called a time slice). At the end of the time slice, the clerk pauses. The current Request is placed on a Pending Requests stack, where it waits for its next share of clerks time.
When implementing the simulation, write a Clerk class that will process the Requests. The Clerk will maintain both the incoming queue of Request objects and the stack of pending Requests.
As previously stated, on every time slice, the current Request (if there is one) is placed on the Pending Requests stack; if theres a Request waiting to be processed at the front of the input queue that has a higher priority than the Request at the top of the Pending Requests stack, the higher priority Request is removed from the input queue to become the current Request. Otherwise, the Request at the top of the stack is moved back to the Clerk from the Pending Requests stack. All Requests that are processed by the Clerk come from either the input queue or the Pending Requests stack. So, at the beginning of a time slice, the Request having the highest priority is moved from the priority queue or the Pending Requests stack and processed for a time slice.
After a Request has received its designated amount of processing time, it is dispatched to be fulfilled.
Figure 1 gives an example input file showing the format. see image.
..
6: Request #3 arrives
7: Request #1 begins processing
12: Request #3 finishes processing
16: Request #5 dispatched to be fulfilled
When all Requests are processed, you are to report the average wait times in both the input queue and the Pending Requests stack. Average wait time is computed by dividing the total wait time all Requests spent in a queue or stack by the total number of Requests that were processed by the Clerk. Note that a Request waits only if it remains in a queue or stack at the end of a time slice. All program output is to be written to a file called < YourLastName>Output.txt. The standard printHeading() information should be sent to this file before any of the simulation results.
Your program must be able to retrieve the name of the input file from the command line and provide appropriate recovery if the file name is missing or incorrect. Your main program file must be named Project4.java and you should create both Request.java and Clerk.java source code files to model these two entities.
Follow style and documenting examples given in class for earlier projects. Each program file must begin with a comment block with your name, program name, course number, etc. The block must also include the purpose, input, and output of the program.