githubEdit

PE1 (AY23/24)

Session 1

Bus

The tricky point here is that the bus stores its passengers using an array of Queue<Passenger>, and the index of the array represents stops. For example, at stop 0, we have 1 passenger get on the bus. So, the first element in the array, which is a queue, will store this passenger. And when we move to stop 1, another passenger gets on the bus, it will be stored in the second element of the array, which is another queue.

BankSimulation

In Exercise 1 - Simulation 1, there is an important property for simulation, that is the initEvents are sorted by time, meaning that even though the first few events are BusStopEvent, the ArrivalEvent (Passenger Arrival) will still be processed if they happen first.

In short, we don't have to care about the sequence of the events in simulation thanks to the use of priority queue, which used the time as the key!

Session 2

This one is easier as long as you follow the instructions.

Last updated