java.lang.Object Gorilla
public class Gorilla
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 |
---|
public static final int HEIGHT
public static final int WIDTH
Constructor Detail |
---|
public Gorilla(java.lang.String name)
name
- The name for the new gorilla.Method Detail |
---|
public java.lang.String getName()
public int getLeft()
public int getMiddle()
public int getBottom()
public void place(int left, int bottom)
left
- The x coordinate of the bottom left corner of the gorilla.bottom
- The y coordinate of the bottom left corner of the gorilla.public int getScore()
public boolean wasHit()
public boolean isStillPlaying()
public void addToScore(int points)
points
- The number of points to add to the gorilla's score (can be negative)public void resetScore()
public void setWasHit(boolean wasHit)
wasHit
- true if the gorilla was hit, false otherwisepublic void removeFromGame()
public void putInGame()
public java.lang.String toString()
toString
in class java.lang.Object