Class WumpusMaze
java.lang.Object
|
+--WumpusMaze
- class WumpusMaze
- extends java.lang.Object
WumpusMaze.java -
Object that represents the maze in which the
"Hunt the Wumpus" game is played. This maze
is constructed from an interconnected collection
of WumpusCave objects.
- Version:
- 4/5/2000
- Author:
- Grant William Braught, Dickinson College
|
Constructor Summary |
WumpusMaze()
Constructor that reads in the data file describing the
maze and constructs it. |
|
Method Summary |
boolean |
feel()
Feel the air for a breeze that would be coming from
a pit in an adjacent cave. |
java.lang.String |
getAdjCaveName(int theTunnel)
Return the name of the cave that would be reached by
following the indicated tunnel from the current cave. |
java.lang.String |
getCaveName()
Return the name of the cave currenly occupied by the
player. |
boolean |
isAlive()
Check to see if the player in the maze is still alive. |
boolean |
listen()
Listen to see if you can hear the flapping wings of
the bats in an adjacent cave. |
boolean |
liveWumpi()
Check to see if there are still more wumpi in the
maze that need a good killing. |
void |
move(int theTunnel)
Move though a tunnel into an adjacent cave. |
boolean |
smell()
Smell the air to see if a wumpus is about. |
void |
tossGrenade(int theTunnel)
Toss a grenade through a tunnel into an adjacent
cave in an attempt to kill a wumpus. |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WumpusMaze
public WumpusMaze()
- Constructor that reads in the data file describing the
maze and constructs it. This includes creating the
WumpusCave objects and indicating how the caves are
connected. This constructor also randomly places wumpi,
bats and pits in the maze and picks a random starting cave
for the player. The player will always be started in an
empty cave.
feel
public boolean feel()
- Feel the air for a breeze that would be coming from
a pit in an adjacent cave. Returns true if any of the
caves adjacent to the current cave contain a pit.
- Returns:
- true if any of the adjacent caves contain a
pit and false otherwise.
getAdjCaveName
public java.lang.String getAdjCaveName(int theTunnel)
- Return the name of the cave that would be reached by
following the indicated tunnel from the current cave.
- Parameters:
theTunnel - the tunnel- Returns:
- the the name of the cave at the end of theTunnel.
getCaveName
public java.lang.String getCaveName()
- Return the name of the cave currenly occupied by the
player.
- Returns:
- the the name of the cave currenly occupied by the
player.
isAlive
public boolean isAlive()
- Check to see if the player in the maze is still alive.
- Returns:
- true if the player is alive and false if they
have been killed.
listen
public boolean listen()
- Listen to see if you can hear the flapping wings of
the bats in an adjacent cave. Returns true if any
of the caves adjacent to the current cave contain bats.
- Returns:
- true if any of the adjacent caves contain bats
and false otherwise.
liveWumpi
public boolean liveWumpi()
- Check to see if there are still more wumpi in the
maze that need a good killing.
- Returns:
- true if there is at least one more live wumpus
in the maze and false if all wumpi are dead.
move
public void move(int theTunnel)
- Move though a tunnel into an adjacent cave. If there is
a wumpus in the new cave the player is instantly trounced
to death by the wumpus. If there is a pit in the new
cave the player falls into the pit and is killed. If there
are bats in the cave the player is flown away to a random
cave in the maze.
- Parameters:
theTunnel - the tunnel through which to move.
smell
public boolean smell()
- Smell the air to see if a wumpus is about. Returns
true if any of the caves adjacent to the current
cave contain a wumpus.
- Returns:
- true if any of the adjacent caves contain
a wumpus and false otherwise.
tossGrenade
public void tossGrenade(int theTunnel)
- Toss a grenade through a tunnel into an adjacent
cave in an attempt to kill a wumpus. If a wumpus
is in that cave it is killed. Any wumpi in caves
adjacent to where the grenade exploded run in fear
through a tunnel to an adjacent cave (possibly
killing the player if they arrive in the current
cave!)
- Parameters:
theTunnel - the tunnel though which the grenade
should be tossed.