Class Gorilla

java.lang.Object
  extended by Gorilla

public class Gorilla
extends java.lang.Object

This class represents a player in the game. It keeps track of the following informpation about the player:

Field Summary
static int HEIGHT
          The height of a gorilla
static int WIDTH
          The width of a gorilla
 
Constructor Summary
Gorilla(java.lang.String name)
          Creates a new gorilla with the specified name.
 
Method Summary
 void addToScore(int points)
          Changes the gorilla's score by the given amount.
 int getBottom()
          Returns the y coordinate of the bottom left corner of the gorilla.
 int getLeft()
          Returns the x coordinate of the bottom left corner of the gorilla.
 int getMiddle()
          Returns the x coordinate of the bottom left corner of the gorilla plus half the gorilla's width rounded down.
 java.lang.String getName()
          Returns the name of this gorilla.
 int getScore()
          Returns how many points this gorilla has.
 boolean isStillPlaying()
          Indicates whether this gorilla is still in the game.
 void place(int left, int bottom)
          Sets where this gorilla is in the game area by specifying the position of the gorillas bottom left corner.
 void putInGame()
          The gorilla is now again participating in the game after this method is called.
 void removeFromGame()
          The gorilla is not participating in the game after this method is called.
 void resetScore()
          Sets the gorilla's score to zero.
 void setWasHit(boolean wasHit)
          Set whehther the gorilla was hit by a banana this round.
 java.lang.String toString()
           
 boolean wasHit()
          Indicates whether this gorilla was hit by a banana or an explosion shock wave this round.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HEIGHT

public static final int HEIGHT
The height of a gorilla


WIDTH

public static final int WIDTH
The width of a gorilla

Constructor Detail

Gorilla

public Gorilla(java.lang.String name)
Creates a new gorilla with the specified name.

Parameters:
name - The name for the new gorilla.
Method Detail

getName

public java.lang.String getName()
Returns the name of this gorilla.

Returns:
the name of this gorilla

getLeft

public int getLeft()
Returns the x coordinate of the bottom left corner of the gorilla.

Returns:
the x coordinate of the bottom left corner of the gorilla

getMiddle

public int getMiddle()
Returns the x coordinate of the bottom left corner of the gorilla plus half the gorilla's width rounded down. This method is provided for convenience.

Returns:
the x coordinate of the bottom left corner of the gorilla plus half the gorilla's width rounded down.

getBottom

public int getBottom()
Returns the y coordinate of the bottom left corner of the gorilla.

Returns:
the y coordinate of the bottom left corner of the gorilla

place

public void place(int left,
                  int bottom)
Sets where this gorilla is in the game area by specifying the position of the gorillas bottom left corner.

Parameters:
left - The x coordinate of the bottom left corner of the gorilla.
bottom - The y coordinate of the bottom left corner of the gorilla.

getScore

public int getScore()
Returns how many points this gorilla has.

Returns:
how many points this gorilla has

wasHit

public boolean wasHit()
Indicates whether this gorilla was hit by a banana or an explosion shock wave this round.

Returns:
whether this gorilla was hit by a banana or an explosion shock wave this round.

isStillPlaying

public boolean isStillPlaying()
Indicates whether this gorilla is still in the game. This method should return true unless it's overtime and the gorilla did not share the high score at the beginning of overtime.

Returns:

addToScore

public void addToScore(int points)
Changes the gorilla's score by the given amount.

Parameters:
points - The number of points to add to the gorilla's score (can be negative)

resetScore

public void resetScore()
Sets the gorilla's score to zero.


setWasHit

public void setWasHit(boolean wasHit)
Set whehther the gorilla was hit by a banana this round.

Parameters:
wasHit - true if the gorilla was hit, false otherwise

removeFromGame

public void removeFromGame()
The gorilla is not participating in the game after this method is called.


putInGame

public void putInGame()
The gorilla is now again participating in the game after this method is called.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object