/* Car Wash Simulation Project: Bay 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 Added Bay class. Copyright 2000 Autumn C. Spaulding and Alyce Brady 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 represents a car wash bay in the Car Wash program. In particular, it keeps track of when the bay is empty or, if there is a car being washed, how long it will be until the bay is empty again. */ public class Bay { int timeLeftTillEmpty; /** Construct a Car Wash Bay */ public Bay () { reset(); } /** Re-initialize the bay for the start of a new run of the simulation. */ public void reset () { // reset bay to be empty /******************************************************************** * * * Code missing: See comments above. * * * ********************************************************************/ } /** Is the bay empty, or is there a car in it being washed? */ public boolean isEmpty () { return timeLeftTillEmpty <= 0; } /** Start washing a new car. This function sets the timer to show many more minutes it will take to finish washing this new car. */ public void startWash () // pre: isEmpty() { // Car wash takes 3 minutes (current minute plus 2 more) /******************************************************************** * * * Code missing: See comments above. * * * ********************************************************************/ } /** This function tells the bay about the passage of time as it washes a car. */ public void keepWashing () // pre: ! isEmpty() // post: bay is one unit of time closer to being empty { // Check that pre-condition is met to ensure that we don't go // into negative numbers! /******************************************************************** * * * Code missing: See comments above. * * * ********************************************************************/ } } // end Bay class