FileDocCategorySizeDatePackage
Radio.javaAPI DocExample1689Sun Feb 13 17:12:30 GMT 2000gui2000

Radio

public class Radio extends Observable implements Observer
The Radio simulates radio contact with all the aircraft in a particular simulated airspace.
author
T Balls
version
0.1, 12-12-99
see
gui2000.AirSpace

Fields Summary
private Vector
aircraft
Constructors Summary
public Radio(Vector theAircraft)

  aircraft = theAircraft; 
   
Methods Summary
public voidbroadcast(java.lang.String callsign, java.lang.String message)
Send a message to an aircraft

param
callsign - the aircraft's call sign (squawk code)
param
message the String to be sent to the aircraft

  for( int i = 0; i < aircraft.size(); i++ )
      {  Aircraft theOne = (Aircraft)(aircraft.elementAt(i));   
         if( theOne.getData().callSign.equals( callsign ) )
         {  theOne.order( message );    
            return;
         }
      } 
   
public voidupdate(java.util.Observable o, java.lang.Object message)
Called by each Aircraft when there is a message to pass to the air traffic controller.

The method prepends the call sign to the message before passing it to any Observers registered.

                           
   
                                        
          
     if( (o instanceof Aircraft) && (message instanceof String) )
      {  setChanged();
         notifyObservers( ((Aircraft)o).getData().callSign + ": " + message );
      }