Overview Schedule Announcements Resources Assignments Home

CSC 121: Computer Science I, Spring 2005

In-Class Exercise: Bank Simulation

Bank Simulation (Project 3)

Goals:
To prepare for project 3: A bank simulation using queues, randomization and gathering statistics.
Getting started:
The Steps of the Lab:
  1. Complete the following.
    Observe

    Examine the project's class diagram:

    • Bank uses Teller, Queue, and CustomerSource objects directly, and Customer objects indirectly through the CustomerSource class.
    • Teller uses Bank, Queue, and Customer (from Queue).
    • Queue uses Bank and Customer.
    • CustomerSource uses Customer and Bank.
    Answer
    • What fields define a Customer? What other data are required in order to compute the total time a customer spent in the Bank? A Teller requests the recording of start of service in its serve method. What exactly is recorded and how are customer fields used in the calculation?
    • What does a Teller do when it finishes with a Customer?
    Do

    Complete task 7 of Project 3.

    Answer
    • The runSimulation method in the Bank class needs to know whether to process a customer arrival or a customer departure as its next task. To make this decision, it needs to know when the next Customer will arrive (and when a Customer will next depart from a Teller). Look in the CustomerSource class and describe when the time of the next Customer arrival is generated. Where is this method called in the Bank class and why does the time of next arrival need to be established here?
    • Read the field definitions of the Bank class. They are separated into groups according to function: simulation components, simulation parameters, and statistics. List and describe the simulation parameter fields.
    Do

    Complete task 1 of Project 3.

    The loadFileParameters() method can be used instead of loadDefaultParameters() to initialize the simulation parameter fields. This method reads values for these fields from a text file instead of setting them within the simulation itself as in loadDefaultParameters(). Create an instance of Bank. Invoke the loadDefaultParameters() method and then inspect the Bank object. Compare the simulation parameter values with those in the loadDefaultParameters() method. Now invoke the loadFileParameters() method. A file open dialog box will appear. Choose the lab8parameters.txt file in the Bank folder. Now inspect the Bank object. Have the values of the simulation fields changed? How would you check to see that they are the correct values?

Overview Schedule Announcements Resources Assignments Home

Valid HTML 4.01!Valid CSS!DePauw University , Computer Science Department , Spring 2005
Maintained by Brian Howard ( bhoward@depauw.edu ). Last updated