/*
Car Wash Simulation Project: CarWashSimulation Class
The Car Wash Simulation Project is described in
Car
Wash Project Description.
Authors: Autumn C. Spaulding and Alyce Brady,
based on a description by
Todd Ollendyke.
Date: 13 July 2000
Modified: 12 October 2000
Separated simulation behavior from main into the CarWashSimulation class.
Modified: 29 October 2002
Separated class templates into separate files.
Modified: 27 October 2003
Set up waitingLine to use LLQueue instead of QueueVector. (Pamela Cutter)
Copyright 2000, 2002, 2003 Autumn C. Spaulding, Alyce Brady, and Pamela Cutter
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
This class is a template, or starting point, for
a class that will manage the simulation of cars arriving at a car
wash, waiting in line, and going through the wash cycle.
*/
public class CarWashSimulation
{
int currentTime; // how many minutes the car wash has been open
int closingTime; // when the car wash should close
Bay bay; // car wash bay
Queue waitingLine; // line of cars waiting to be washed
int totalWaitingTime; // total time spent waiting by all cars
int numCars; // how many cars were washed
TempRandom randGen; // random number generator
/* Construct a car wash simulation object. */
public CarWashSimulation ()
{
bay = new Bay();
waitingLine = new LLQueue();
randGen = new TempRandom();
reset();
}
/** Reset the state of the simulation for a new run. */
public void reset ()
{
// All times and number of cars should be reset to 0 (closingTime
// will be set to the appropriate value when the simulation is run).
// The bay and waitingLine should be reset using appropriate
// methods from their classes.
/********************************************************************
* *
* Code missing: See comments above. *
* *
********************************************************************/
}
/** Run the simulation for a specified number of minutes (or whatever the
unit for a single step of the simulation is).
@param minutesToRun the number of steps of the simulation to run
*/
public void run (int minutesToRun)
{
closingTime = minutesToRun;
// Run for as many minutes as specified or until there are no cars
// left waiting to be washed, whichever is longer.
/********************************************************************
* *
* Code missing: See comments above. *
* *
********************************************************************/
// Print results of simulation.
/********************************************************************
* *
* Code missing: See comments above. *
* *
********************************************************************/
}
/** Execute a single step of the simulation.
*/
public void step ()
{
/********************************************************************
* *
* Code missing: See pseudo-code in problem description. *
* *
********************************************************************/
currentTime++;
}
} // end CarWashSimulation class