Write a constructor for a class Event; the instances of this class will be used to represent
Question:
Write a constructor for a class Event; the instances of this class will be used to represent simulation events. Each instance should have properties time (assume that this is a Number) and type (of arbitrary type). Your constructor should have two arguments corresponding to these properties, so that the properties can be initialized easily when an instance is constructed. (b) Write a constructor and methods for a class EventQueue representing an event queue. There should be a method empty() that returns true if and only if the queue is empty; a method add() that takes an Event object as its argument and adds it to the queue; and a method removeNextEvent() that removes the Event with the smallest time value (breaking ties arbitrarily) from the event queue and returns this object. (c) Use the classes of (a) and (b) to write a simple airline ticket counter simulation. Input the number of ticket agents working at the counter. The event queue should be initialized by adding a number of customer-arrival events at various times, each time being an integer representing the number of minutes since the ticket counter opened. The program should then begin processing the event queue by removing the first event. If no agent is free when a customer-arrival event occurs, an element containing the current time should be pushed onto a data structure representing the waiting line at the ticket counter (so each element of the line structure represents a customer by the time at which the customer entered the line). If an agent is free when a customer-arrival event occurs, then the number of busy agents is incremented and a transaction-complete event is scheduled to occur three minutes later. When a transaction-complete event occurs, if any customers are in the waiting-line structure, then the first customer is removed from the line and the length of time that customer waited in line is added to an accumulator variable; the number of busy agents is unchanged. Otherwise, if no customers are waiting, an agent becomes free. The simulation ends when no events remain in the event queue. At this time, average customer wait time (accumulated wait time divided by number of customers) is output. 4.21. Write a JavaScript program that will allow a user to test the speed at which alert boxes are generated by a particular browser running on a particular system. Specifically, the program will display an alert box, then display a second alert box after OK is clicked in the first alert box, display a third alert box when the second is acknowledged, and so on. The program will stop displaying these alert boxes once 10 seconds has elapsed from the time the first box was displayed (so dividing by 10 will give the number of boxes displayed per second). Then, for 2 seconds, the program should repeatedly display alert boxes that report on the number of clicks per second recorded during the first 10 seconds (the reason for doing this for 2 seconds is so that you can see the results even if you accidentally click OK on one or more of the result alert boxes). For timing, use only the built-in Date object and its methods; that is, don't use any other timing-related host objects that might be available in your browser. Report on the results of testing with various browsers and systems.
Introduction to Management Science A Modeling and Cases Studies Approach with Spreadsheets
ISBN: 978-0078024061
5th edition
Authors: Frederick S. Hillier, Mark S. Hillier