Class FinchModel

java.lang.Object
  extended by FinchModel

public class FinchModel
extends java.lang.Object


Field Summary
private  java.util.ArrayList<java.awt.event.ActionListener> actionListenerList
          List of ActionListeners
private  java.util.Random generator
           
private  int[] light
          Local copy of the current light levels
private  finch.Finch myFinch
          Reference to the Finch object
private  double temperature
          Local copy of the current temperature
 
Constructor Summary
FinchModel(finch.Finch myFinch)
          Constructor
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Add an ActionListener to the listener list Note: this method is declared as "synchronized" so that only one thread is operating on the actionListenerList at once (each of our Window objects have their own threads) Implementation from Listing 32.2 of Introduction to Java (Liang)
 int[] getLight()
          Accessor
 double getTemperature()
          Accessor
private  void processEvent(java.awt.event.ActionEvent e)
          Alert the listeners that a new event has occurred Implementation from Listing 32.2 of Introduction to Java (Liang)
 void removeActionListener(java.awt.event.ActionListener listener)
          Remove an ActionListener to the listener list Implementation from Listing 32.2 of Introduction to Java (Liang)
 void updateLight()
          Called by controller to force the model to update its currently stored light levels.
 void updateTemperature()
          Called by controller to force the model to update its currently stored temperature level TODO: Complete implementation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myFinch

private finch.Finch myFinch
Reference to the Finch object


temperature

private double temperature
Local copy of the current temperature


light

private int[] light
Local copy of the current light levels


actionListenerList

private java.util.ArrayList<java.awt.event.ActionListener> actionListenerList
List of ActionListeners


generator

private java.util.Random generator
Constructor Detail

FinchModel

public FinchModel(finch.Finch myFinch)
Constructor

Parameters:
myFinch - Reference to the Finch object. If null, then assumes that no Finch is connected (and will fill in random data)
Method Detail

updateLight

public void updateLight()
Called by controller to force the model to update its currently stored light levels.

TODO: complete implementation


updateTemperature

public void updateTemperature()
Called by controller to force the model to update its currently stored temperature level

TODO: Complete implementation


getTemperature

public double getTemperature()
Accessor

Returns:
Currently stored temperature value

getLight

public int[] getLight()
Accessor

Returns:
Currently stored light values

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Add an ActionListener to the listener list

Note: this method is declared as "synchronized" so that only one thread is operating on the actionListenerList at once (each of our Window objects have their own threads)

Implementation from Listing 32.2 of Introduction to Java (Liang)

Parameters:
listener - Reference to the listener to be added

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Remove an ActionListener to the listener list Implementation from Listing 32.2 of Introduction to Java (Liang)

Parameters:
listener - Listener to be removed

processEvent

private void processEvent(java.awt.event.ActionEvent e)
Alert the listeners that a new event has occurred Implementation from Listing 32.2 of Introduction to Java (Liang)

Parameters:
e - ActionEvent to be sent