Assignment 3

Due on Friday 1st May

You may work in groups of one, two or three for this assignment.

Question 1

Consider question 1 from homework 2 (about modelling supermarket cashier queues). Write a program to give a GUI display of the behaviours of these queues over time. You should keep good separation between the code handling the queues and the GIU code (hence leverage the fact that you've already written the simulation program!). You should represent the queues of 'people' as lines of biggish dots, with 'impatient' folk changing to red shortly before they skip their current queue to join the back of another one (remaining red for a short time after arrival so that we can see who went where). You should consider how you want to display the queues changing over time so that things don't happen so quickly that we can't see anything useful. You should also institute an 'opportunity cost' associated with skipping a queue to join another by making it take some modifiable amount of time, and experiment with your program so that the overall result looks interesting.

Question 2

Model a transport network (e.g, of roads and intersections) using a graph. You will need classes for vehicles (have at least classes for cars, buses, bicycles, ambulances), using inheritance where possible. You will need a class for the transport network itself (allowing for both one-way streets and two-way streets). You should arrange things so that depending on various natural conditions (your reasonable choice, well-commented of course!), priorities can be set (for example, buses win over cars, bicycles win over buses, ambulances win over everything if running in an emergency state). Have your main method input a file to initialise things, and then run a simulation with selective output to the screen (and full output to an output file) to show how transport moves around your system and various levels of congestion are handled. providing a GUI (using swing) to display and control the simulation and to display interesting data about its behaviour.