model.fish.tests
Class Test_GenericFish.TestAllWayLocalEnv

java.lang.Object
  extended bymodel.fish.tests.Test_GenericFish.TestAllWayLocalEnv
All Implemented Interfaces:
ILocalEnv
Enclosing class:
Test_GenericFish

private static class Test_GenericFish.TestAllWayLocalEnv
extends java.lang.Object
implements ILocalEnv


Constructor Summary
private Test_GenericFish.TestAllWayLocalEnv()
           
 
Method Summary
 void drawFish(AFish fish, java.awt.Graphics2D g, java.awt.Component comp)
          Draw the fish on the graphics object.
 java.lang.Object execute(AGlobalEnv.ILocalEnvVisitor visitor, java.lang.Object param)
          Execute a visitor on this local environment.
 void removeFish(AFish fish)
          Remove the fish from the environment.
 void setState(ILocalEnvState state)
          Set state.
 java.lang.Object tryBreedFwd(AFish fish, ILambda blockedCmd, ILambda openCmd)
          Attempt to breed the fish forward, which may or may not be successful.
 java.lang.Object tryMoveFwd(AFish fish, ILambda blockedCmd, ILambda openCmd)
          Attempt to move the fish forward, which may or may not be successful.
 void turnRight(AFish fish, double radians)
          Turn the fish radians to the right.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface sysModel.env.ILocalEnv
toString
 

Constructor Detail

Test_GenericFish.TestAllWayLocalEnv

private Test_GenericFish.TestAllWayLocalEnv()
Method Detail

tryMoveFwd

public java.lang.Object tryMoveFwd(AFish fish,
                                   ILambda blockedCmd,
                                   ILambda openCmd)
Description copied from interface: ILocalEnv
Attempt to move the fish forward, which may or may not be successful. The behavior in each case is defined by the visitor: - If the move cannot be executed, the blockedCmd lambda is applied. The parameter is not used and set to null. - If the move can be executed, the openCmd lambda is applied. The parameter is an ILambda that can to be executed to actually move the fish to the target location of this move. The ILambda ignores the input parameter and returns null.

Specified by:
tryMoveFwd in interface ILocalEnv
Parameters:
fish - AFish to move
blockedCmd - lambda to apply if blocked
openCmd - lambda to apply if open
Returns:
return value of lambda executed

tryBreedFwd

public java.lang.Object tryBreedFwd(AFish fish,
                                    ILambda blockedCmd,
                                    ILambda openCmd)
Description copied from interface: ILocalEnv
Attempt to breed the fish forward, which may or may not be successful. The behavior in each case is defined by the visitor: - If the breeding cannot be executed, the blockedCmd lambda is applied. The parameter is not used and set to null. - If the breeding can be executed, the openCmd lambda is applied. The parameter is an ILambda that can to be executed to actually move the fish to the target location of this breeding. The ILambda ignores the input parameter and returns null.

Specified by:
tryBreedFwd in interface ILocalEnv
Parameters:
fish - AFish to move
blockedCmd - lambda to apply if blocked
openCmd - lambda to apply if open
Returns:
return value of lambda executed

drawFish

public void drawFish(AFish fish,
                     java.awt.Graphics2D g,
                     java.awt.Component comp)
Description copied from interface: ILocalEnv
Draw the fish on the graphics object. The graphics object still has to be translated and rotated properly,

Specified by:
drawFish in interface ILocalEnv
Parameters:
fish - AFish to drawFish
g - graphics object to drawFish on
comp - component to drawFish on

turnRight

public void turnRight(AFish fish,
                      double radians)
Description copied from interface: ILocalEnv
Turn the fish radians to the right.

Specified by:
turnRight in interface ILocalEnv
Parameters:
fish - AFish to turn
radians - radians to turn

removeFish

public void removeFish(AFish fish)
Description copied from interface: ILocalEnv
Remove the fish from the environment.

Specified by:
removeFish in interface ILocalEnv
Parameters:
fish - AFish to remove

execute

public java.lang.Object execute(AGlobalEnv.ILocalEnvVisitor visitor,
                                java.lang.Object param)
Description copied from interface: ILocalEnv
Execute a visitor on this local environment.

Specified by:
execute in interface ILocalEnv
Parameters:
visitor - visitor to execute
param - visitor-specific parameter
Returns:
visitor-specific return value

setState

public void setState(ILocalEnvState state)
Description copied from interface: ILocalEnv
Set state.

Specified by:
setState in interface ILocalEnv
Parameters:
state - new state