Menu

Discrete Event Simulation Simulate Events Occurring Discrete Time Points Two Consecutive T Q43785333

Discrete eventsimulation is to simulate events occurring at discrete time points.Between any two consecutive time points, no event occurs.

  1. Write a class Event with two integer instance variable time andtype, which represents an event of a specific type occurs at time.Also write the constructor Event(int time, int type), whichinitializes the attributes using the parameters. In using thisclass, you can assume the getter and setter methods areavailable.

  1. Write a class Bank with an attribute eventList, which is alist of Event. Add a method

generateEvents(int n) which generatesn random customer arrival events (with event type

0) and put them intoeventList in the order of increasing arrival times. The arrivaltime of the first customer is a random integer between 0 to 10(inclusively). Similarly, after the first customer has arrived, thetime to wait for the next customer to arrive, the interarrivaltime, is also a random integer between 0 to 10. Other futurecustomer arrivals are similar. For example, if the first customerarrives at 3 and the next 2 interarrival times are 2 and 4, theactual customer arrival times are 3, 5 (=3+2) and 9 (=5+4).

  1. Write a method waitingTime(int serviceTime) of Bank whichreturns the average waiting time of the customers whose arrivaltimes are in eventList, where serviceTime is the time each customerbeing served at the bank counter. In other words, the servicingtime of each customer is the same.

Expert Answer


Answer to Discrete event simulation is to simulate events occurring at discrete time points. Between any two consecutive time poin…

OR