In this lab, you will be designing a Java applet that simulates an air conditioner. The applet will have an interface that allows the user to specify the outside temperature, the inside temperature, and the desired temperature. The air conditioner has four different modes for heating and cooling (stop, low, medium, and high). You will be writing a controller that changes the air conditioner mode during simulation to make the inside temperature match the desired temperature. You will be provided with code that modifies the temperature. An example of the applet is shown above. If for some reason it doesn't work on your browser, download the classes and run them on appletviewer (AirConditioner is the main class): Interface.class, Controller.class, TemperatureUpdater.class, AirConditioner.class, AirConditioner$TimeUpdater.class
This lab consists of four parts, which have been split into their own Java
classes. The provided files have comments describing each method and
variable. Further details will be provided in lab. Each class is decribed
below:
/** * METHOD: setInitialTemperature * DESCRIPTION: This method sets the initial temperature to be used. * PARAMETERS: double inside - the initial inside temperature * double outside - the initial outside temperature * RETURNS: nothing */ void setInitialTemperature(double inside, double outside) /** * METHOD: update * DESCRIPTION: This method updates the inside temperature based on * the time that has passed since the last update, * the heating mode, and the cooling mode. * PARAMETERS: int milliseconds - specifies the time that has passed * since the last update * int heatMode - specifies the heating mode that has * been applied since the last update * int coolMode - specifies the cooling mode that has * been applied since the last update * RETURNS: nothing */ public void update(int milliseconds, int heatMode, int coolMode) /** * METHOD: getInsideTemperature * DESCRIPTION: This method returns the current inside temperature * PARAMETERS: none * RETURNS: double, specifying the current inside temperature */ public double getInsideTemperature()setInitialTemperature() should be used at the start of a simulation to set the original inside and outside temperature. update() should be called on every timer event to determine the new inside temperature. getInsideTemperature() should be used to determine the new inside temperature after a call to update(). Download the class file here.