// This example is from the book Developing Java Beans by Robert Englander.
// Copyright (c) 1997 O'Reilly & Associates.
// You may study, use, modify, and distribute this example for any purpose.
// This example is provided WITHOUT WARRANTY either expressed or implied.

// Chapter 3 -- The second version of class Thermometer

package BeansBook.Simulator;

public class Thermometer
{
   // references to the two temperature objects that we are monitoring
   protected Temperature theTemperature1;
   protected Temperature theTemperature2;

   // the temperature change adapter
   protected GenericTemperatureAdapter tempAdapter;

   // constructor
   Thermometer(Temperature temperature1, Temperature temperature2)
   {
      // save references to the temperature objects
      theTemperature1 = temperature1;
      theTemperature2 = temperature2;

      // create the adapter
      tempAdapter = new GenericTemperatureAdapter(this);
   
      try
      {
         // register the handler methods
         tempAdapter.registerEventHandler(theTemperature1, "temperature1Changed");
         tempAdapter.registerEventHandler(theTemperature2, "temperature2Changed");
      }
      catch (NoSuchMethodException e)
      {
         System.out.println(e);
      }
   }

   // handle changes to Temperature object 1
   public void temperature1Changed(TempChangedEvent evt)
   {
   }

   // handle changes to Temperature object 2
   public void temperature2Changed(TempChangedEvent evt)
   {
   }
}