demo.helicopter
Class RelationshipRedSquad

java.lang.Object
  extended bydemo.helicopter.RelationshipRedSquad
All Implemented Interfaces:
Relationship

public class RelationshipRedSquad
extends java.lang.Object
implements Relationship

Red Squad relationship

Since:
JDK1.3
Version:
0.2, 20 Jul 00
Author:
Michael R. Dickson, Kimberly A. Roddy

Field Summary
 int maxMembers
          Maximum allowed members in a red squad relationship.
 int minMembers
          Minimum allowed members in a red squad relationship.
 
Constructor Summary
RelationshipRedSquad()
          No-argument constructor for RelationshipSquad class
 
Method Summary
 boolean addAgent(Agent pCTFAgent)
          Adds the passed in agent to the list of members of this relationship.
 boolean conditionsMaintained()
          Verifies conditions are maintained to continue this relationship.
 boolean conditionsMet(Agent pCTFAgent, java.util.Vector sensedAgents)
          Verifies conditions are met to form this relationship.
 void destroyRelationship()
          When conditions are no longer met to maintain this relationship, this method is called.
 java.lang.String getClassName()
          Returns The class name of this relationship.
 int getIDNumber()
          Returns the ID number of this relationship.
 java.util.Vector getMembers()
          Returns the vector of members currently in this relationship
 void issueRoles()
          Issues the appropriate roles to each member in the relationship.
 boolean removeAgent(Agent pCTFAgent)
          Removes the passed in agent from the list of members of this relationship.
 void setClassName(java.lang.String pClassName)
          Sets the class name of this relationship
 void setIDNumber(int pID)
          Sets the ID number of this relationship
 java.lang.String toString()
          Returns a formated description of this relationship suitable for printing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

maxMembers

public int maxMembers
Maximum allowed members in a red squad relationship.


minMembers

public int minMembers
Minimum allowed members in a red squad relationship.

Constructor Detail

RelationshipRedSquad

public RelationshipRedSquad()
No-argument constructor for RelationshipSquad class

Method Detail

conditionsMet

public boolean conditionsMet(Agent pCTFAgent,
                             java.util.Vector sensedAgents)
Verifies conditions are met to form this relationship.

Specified by:
conditionsMet in interface Relationship
Parameters:
pCTFAgent - The agent attempting to form the relationship
sensedAgents - A vector containing all of the sensed agents
Returns:
The success of verifying conditions are met:
  • true - Conditions are met
  • false - Conditions are not met

  • conditionsMaintained

    public boolean conditionsMaintained()
    Verifies conditions are maintained to continue this relationship. If they are not, it calls the destroyRelationship method.

    Specified by:
    conditionsMaintained in interface Relationship
    Returns:
    The success of verifying conditions are maintained:
  • true - Conditions are maintained
  • false - Conditions are not maintained

  • destroyRelationship

    public void destroyRelationship()
    When conditions are no longer met to maintain this relationship, this method is called. It removes all reference to itself from agents in its members list as well as the RelationshipManager

    Specified by:
    destroyRelationship in interface Relationship

    issueRoles

    public void issueRoles()
    Issues the appropriate roles to each member in the relationship.

    Specified by:
    issueRoles in interface Relationship

    addAgent

    public boolean addAgent(Agent pCTFAgent)
    Adds the passed in agent to the list of members of this relationship.

    Specified by:
    addAgent in interface Relationship
    Parameters:
    pCTFAgent - The agent to be added to this relationship.
    Returns:
    The success of adding the agent:
  • true - pCTFAgent is added
  • false - pCTFAgent was not added

  • removeAgent

    public boolean removeAgent(Agent pCTFAgent)
    Removes the passed in agent from the list of members of this relationship. If this agent was the squad leader, assign squad leader to the next agent.

    Specified by:
    removeAgent in interface Relationship
    Parameters:
    pCTFAgent - The agent to be removed from this relationship.
    Returns:
    The success of removing the agent:
  • true - pCTFAgent is removed
  • false - pCTFAgent was not removed

  • getIDNumber

    public int getIDNumber()
    Returns the ID number of this relationship.

    Specified by:
    getIDNumber in interface Relationship
    Returns:
    ID number

    setIDNumber

    public void setIDNumber(int pID)
    Sets the ID number of this relationship

    Specified by:
    setIDNumber in interface Relationship
    Parameters:
    pID - The new ID number

    setClassName

    public void setClassName(java.lang.String pClassName)
    Sets the class name of this relationship

    Specified by:
    setClassName in interface Relationship
    Parameters:
    pClassName - The new class name

    getClassName

    public java.lang.String getClassName()
    Returns The class name of this relationship.

    Specified by:
    getClassName in interface Relationship
    Returns:
    Class name

    getMembers

    public java.util.Vector getMembers()
    Returns the vector of members currently in this relationship

    Specified by:
    getMembers in interface Relationship
    Returns:
    members

    toString

    public java.lang.String toString()
    Returns a formated description of this relationship suitable for printing

    Specified by:
    toString in interface Relationship
    Returns:
    Relationship string description