Take a few minutes to look over the existing classes to get a feel for
how they work. Try executing MartDriver
several times to
see what the output looks like.
Create a new class that extends Aisle
. As always, you
should think carefully about what to name your class. One common
convention in naming subclasses is to prefix the superclass name
with an adjective the clarifies how the subclass specializes the
superclass. For example, the Car
class might have a
subclass named ElectricCar
.
Your new class must:
addCustomer
method
so that new customers are added only if the line is below some maximum
capacity.Modify the simulation class so that it uses your new Aisle subclass: everywhere "Aisle" appears in the existing class should be replaced with your new class. You should modify the simulation constructor so that it accepts a "maximum length" parameter that describes maximum allowable length for a checkout line.
Modify the printResults
method so that it reports the
total number of customers that left the store because of excessive
line lengths.
Submit your completed Aisle
subclass and
modified MartSimulation
through Autolab. Note that
Autolab will only check that your submission compiles. It is your
responsibility to make sure that the behavior is correct. If you
aren't sure, check with your instructor or a TA.
Each time this simulation is
executed, there is a different result. It might be valuable to know
the average results across many different simulation runs. Add a new
method to the MartSimulation
class with the signature:
public void runMany(int numRuns)This method should run the simulation the indicated number of times, and calculate averages for each of the quantities reported.
It would be useful to be able
to systematically adjust simulation parameters in small increments to
see what effect this has on wait times etc. Add a loop to
your main
that systematically increases the maximum line
length from 0 to 100. For each increment, run your simulation 100
times and report the average results.