Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Discrete event simulation is to simulate events occurring at discrete time points. Between any two consecutive time points, no event occurs. Write a class Event

Discrete event simulation 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 and type, which represents an event of a specific type occurs at time. Also write the constructor Event(int time, int type), which initializes the attributes using the parameters. In using this class, you can assume the getter and setter methods are available.

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

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

0) and put them into eventList in the order of increasing arrival times. The arrival time of the first customer is a random integer between 0 to 10 (inclusively). Similarly, after the first customer has arrived, the time to wait for the next customer to arrive, the interarrival time, is also a random integer between 0 to 10. Other future customer arrivals are similar. For example, if the first customer arrives at 3 and the next 2 interarrival times are 2 and 4, the actual customer arrival times are 3, 5 (=3+2) and 9 (=5+4).

  1. Write a method waitingTime(int serviceTime) of Bank which returns the average waiting time of the customers whose arrival times are in eventList, where serviceTime is the time each customer being served at the bank counter. In other words, the servicing time of each customer is the same.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

Make efficient use of your practice time?

Answered: 1 week ago