Class Neandertal
java.lang.Object
|
+--Player
|
+--Neandertal
- public class Neandertal
- extends Player
This class represents a Neandertal who wanders around in the game doing
some random things.
- Author:
- David Matuszek
|
Field Summary |
(package private) java.lang.String |
name
|
(package private) java.util.Random |
random
|
|
Constructor Summary |
Neandertal(java.lang.String name,
Room startingLocation)
Constructor for Neandertals. |
|
Method Summary |
void |
doSomething()
The Neandertal attempts to do something random. |
private boolean |
maybeDropSomething()
If the Neandertal is holding Things, then approximately half the time
it will drop something. |
private boolean |
maybeMove()
The Neandertal attempts to move in some random direction. |
private boolean |
maybeTakeSomething()
If there are Things here, then approximately half the time
the Neandertal will take something. |
java.lang.String |
toString()
Returns the Neandertal's name. |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait |
random
java.util.Random random
name
java.lang.String name
Neandertal
public Neandertal(java.lang.String name,
Room startingLocation)
- Constructor for Neandertals.
toString
public java.lang.String toString()
- Returns the Neandertal's name.
- Overrides:
toString in class java.lang.Object
doSomething
public void doSomething()
- The Neandertal attempts to do something random.
maybeMove
private boolean maybeMove()
- The Neandertal attempts to move in some random direction.
- Returns:
- true if the Neandertal moves, false otherwise.
maybeDropSomething
private boolean maybeDropSomething()
- If the Neandertal is holding Things, then approximately half the time
it will drop something.
- Returns:
- true if the Neandertal drops something, false otherwise.
maybeTakeSomething
private boolean maybeTakeSomething()
- If there are Things here, then approximately half the time
the Neandertal will take something.
- Returns:
- true if the Neandertal takes something, false otherwise.