ServiceArea.java - DO NOT ADD NEW METHODS OR NEW DATA...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// DO NOT ADD NEW METHODS OR NEW DATA FIELDS! // DO NOT MODIFY METHODS OR NEW DATA FIELDS! package PJ3; import java.util.*; //-------------------------------------------------------------------------- // // Define simulation queues in a service area. Queues hold references to Customer // and Teller objects // // Customer (FIFO) queue is used to hold waiting customers. If the queue is too long // (i.e. > customerQLimnit), customer goes away without entering customer queue // // There are several tellers in a service area. Use PriorityQueue to // hold BUSY tellers and FIFO queue to hold FREE tellers, // i.e. a teller that is FREE for the longest time should start be used first. // // To handle teller in PriorityQueue, we need to define comparator // for comparing 2 teller objects. Here is a constructor from Java API: // // PriorityQueue(int initialCapacity, Comparator<? super E> comparator) // // For priority queue, the default compare function is "natural ordering" // i.e. for numbers, minimum value is returned first // // User can define own comparator class for PriorityQueue. // For teller objects, we like to have smallest end busy interval time first. // i.e. use Teller's getEndBusyIntervalTime() // // The following class define compare() for two tellers : class CompareTellers implements Comparator<Teller>{ // overide compare() method public int compare(Teller o1, Teller o2) { return o1.getEndBusyTime() - o2.getEndBusyTime(); } } class ServiceArea { // Private data fields: // define one priority queue private PriorityQueue <Teller> busyTellerQ; // define two FIFO queues private Queue<Customer> customerQ; private Queue<Teller> freeTellerQ;
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern