PROJECT 2 SUMMER 2002
Back to Projects Main Page

Write a program IN JAVA that simulates a checkout line at a supermarket. The line is a queue object.

Customers (i.e. customer objects) arrive in random integer intervals of 1 to 5 minutes.

Also each customer is serviced in random integer intervals of 1 to 5 minutes.

Obviously the rates need to be balanced. If the average arrival rate is larger than the average service rate , the queue will grow infinitely. Even with balanced rates randomness can cause long lines.

Run the supermarket simulation for a 12 hour day (720 minutes) using the following algorithm:

  • Choose a random integer between 1 and x (see GUI) to determine the minute at which the first customer arrives.
  • At the first customer's arrival:
    • Determine the customer's service time randomly based on the selection from the GUI (see below)
    • Begin servicing the customer
    • Schedule the arrival time of the next customer randomly (1 to x minutes see GUI). Add the time to the current time.
  • For each minute of the day:
    • If the next customer arrives :
      • Enqueue the customer.
      • Schedule the arrival time of the next customer
    • If service was completed for the last customer:
      • Dequeue next customer to be serviced.
      • Determine customer's service completion time to be added to the current time
    • The results of the simulation should be stored in a file.The file could be opened using a text editor like NOTEPAD.

GUI

The GUI should consist of an Applet

The Applet should have the following components that generate the appropriate events:

  • A button that starts the simulation.
  • A button labeled "Statistics". This button 's action event is to display the statistics of the simulation on the text area of the GUI(see description of text area below).
  • A button that exits the simulation (closes the applet and terminates the program execution).
  • A list that allows selection (only one can be chosen) of an arrival rate:
    • 1 to 3
    • 1 to 4
    • 1 to 5
  • A list that allows selection of service time:
    • 1 to 3
    • 1 to 4
    • 1 to 5
  • A display area (Text Area) where the following results can be displayed:
    • Maximum number of customers in the queue during the simulation
    • Longest wait any one customer experienced
    • The above data should be displayed when a button is pressed by the user (labeled "statistics").
  • A file chooser component should be added that will allow access to the the file(s) that contains the output data of the simulation.

The Applet should be displayable using the appletviewer. A security file would be needed in order for the applet to be able to access the output file.

There is no requirement for the applet to work with a regular browser (this would require more advanced security concepts).


You needd to submit on a floppy the following:
  • The Design documentation as per the design guidelines document
  • The source code files
  • The compiled files
  • A sample output file
Grading:
  • Design: 40% 20 points
  • Code/presentation: 60%, 30 points