import ou.
*;
/**
* Objects of the Frog class are simple software representations of frogs.
* The class models them as having the attributes position and colour, and
* hence instance variables of those names.
* The protocol provides messages to set the instance variables and to
* cause changes in an appropriate user interface. Incrementing and
* decrementing a frog's position by a whole number is reflected in an
* appropriate user interface as spatial movement to the user's right and
* left, respectively. (Hence the messages for incrementing and decrementing
* position are called right() and left().)
*
* @author M255 Course Team
* @version 1.0
* Updated by Wiki
* Wiki profile: [Link]
*
*/
public class Frog extends OUAnimatedObject
{
/* Instance variables */
private OUColour colour;
private int position;
/**
* Constructor for objects of class Frog which initialises colour to green
* and position to 1.
*/
public Frog()
{
super();
[Link] = [Link];
[Link] = 1;
}
/* Instance methods */
/**
* Returns the position of the receiver.
*/
public int getPosition()
{
return [Link];
}
/**
* Sets the position of the receiver to the value of the argument aPosition.
*/
public void setPosition (int aPosition)
{
[Link] = aPosition;
[Link]("position");
}
/**
* Sets the colour of the receiver to the argument's colour.
*/
public void sameColourAs (Frog aFrog)
{
[Link]([Link]());
}
/**
* Returns the colour of the receiver.
*/
public OUColour getColour()
{
return [Link];
}
/**
* Sets the colour of the receiver to the value of the argument aColour.
*/
public void setColour(OUColour aColour)
{
[Link] = aColour;
[Link]("colour");
}
/**
* Sets the colour of the receiver to brown.
*/
public void brown()
{
[Link]([Link]);
}
/**
* Sets the colour of the receiver to green.
*/
public void green()
{
[Link]([Link]);
}
/**
* Causes user interface to emit a sound.
*/
public void croak()
{
[Link]("croak");
}
/**
* Resets the receiver to its "home" position of 1.
*/
public void home()
{
[Link](1);
}
/**
* Decrements the position of the receiver by 1.
*/
public void left()
{
[Link]([Link]()-1);
}
/**
* Increments the position of the receiver by 1.
*/
public void right()
{
[Link]([Link]()+1);
}
/**
* Causes a change in an appropriate observing user interface.
* Icon representing the receiver performs a jump animation
*/
public void jump()
{
[Link]("jump");
}
/**
* Returns a string representation of the receiver.
*/
public String toString()
{
return "An instance of class "+ [Link]().getName()
+ ": position " + [Link]()
+ ", colour " + [Link]();
}
}