Class frog.Frog


public class Frog
extends Object
implements frog.IFrog
An implementation of IFrog using external states encapsulated by the frog package.


Variable Index

 o _pos
The current position of the frog
 o _state
The current state of the frog

Method Index

 o getColor ()
Accessor method for the color of the frog
 o getHit ()
The hits the frog
 o getPos ()
Accessor method for the position of the frog
 o moveBy (Point)
Requests that the frog be translated the position by the given vector (Point)
 o setState (AFrogState)
Sets the state of the frog

Variables

 o _pos

private Point _pos = new Point(0,0)

The current position of the frog.

 o _state

private AFrogState _state = LiveState.Singleton

The current state of the frog.

Methods

 o getPos

public Point getPos()

Accessor method for the position of the frog.

Returns:
The current position Point of the frog
 o getColor

public Color getColor()

Accessor method for the color of the frog. A live frog is green and a dead frog is red.

Returns:
The Color of the frog
 o moveBy

public Point moveBy(Point delta)

Requests that the frog be translated the position by the given vector (Point). Live frogs move by the given amount. Dead frogs do not move.

Parameters:
delta - The amount to move the frog by.
Returns:
The resultant position of the frog
 o getHit

public IFrog getHit()

The hits the frog. A live frog will die when it gets hit. A dead frog stays dead when gets hit.

Returns:
The frog itself is returned.
 o setState

void setState(AFrogState s)

Sets the state of the frog.

Parameters:
s - The new state of the frog.