|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.mazewar.Maze
net.mazewar.MazeImpl
public class MazeImpl
A concrete implementation of a Maze.
| Constructor Summary | |
|---|---|
MazeImpl(Point point,
long seed,
java.util.Vector peers)
Create a Maze. |
|
| Method Summary | |
|---|---|
void |
addClient(Client client)
Add a Client at random location in the Maze. |
void |
addClientAtGivenPoint(Client client,
DirectedPoint directedPoint)
|
void |
addMazeListener(MazeListener ml)
Register an object that wishes to be notified when the maze changes |
boolean |
checkBounds(Point point)
Check whether a Point is within the bounds of the Maze. |
boolean |
clientFire(Client client)
Create a new Projectile from the specified Client |
void |
clientUpdate(Client c,
ClientEvent ce)
Listen for notifications about action performed by Clients in the maze. |
Cell |
getCell(Point point)
Obtain the Cell corresponding to a given Point in the Maze. |
Direction |
getClientOrientation(Client client)
Find out the cardinal direction a Client is facing. |
Point |
getClientPoint(Client client)
Find out where a specified Client is located
in the Maze. |
java.util.Iterator |
getClients()
Obtain an Iterator over all Clients in the Maze |
Point |
getSize()
Obtain a Point describing the size of the Maze. |
boolean |
moveClientBackward(Client client)
Attempt to move a Client in the Maze backward. |
boolean |
moveClientForward(Client client)
Attempt to move a Client in the Maze forward. |
void |
print()
Display an ASCII version of the maze to stdout for debugging purposes. |
static Maze |
readMazeFile(java.lang.String mazefile)
Create a maze from a serialized MazeImpl object written to a file. |
void |
removeClient(Client client)
Remove the specified Client from the Maze |
void |
removeMazeListener(MazeListener ml)
Remove an object from the notification queue |
void |
rotateClientLeft(Client client)
Internal helper called when a Client emits a turnLeft action. |
void |
rotateClientRight(Client client)
Internal helper called when a Client emits a turnRight action. |
void |
run()
Control loop for Projectiles. |
void |
save(java.lang.String mazefile)
Serialize this MazeImpl to a file. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MazeImpl(Point point,
long seed,
java.util.Vector peers)
Maze.
point - Treat the Point as a magintude specifying the
size of the maze.seed - Initial seed for the random number generator.| Method Detail |
|---|
public static Maze readMazeFile(java.lang.String mazefile)
throws java.io.IOException,
java.lang.ClassNotFoundException
MazeImpl object written to a file.
mazefile - The filename to load the serialized object from.
MazeImpl.
java.io.IOException
java.lang.ClassNotFoundException
public void save(java.lang.String mazefile)
throws java.io.IOException
MazeImpl to a file.
mazefile - The filename to write the serialized object to.
java.io.IOExceptionpublic void print()
public boolean checkBounds(Point point)
MazePoint is within the bounds of the Maze.
checkBounds in class Mazetrue if the point lies within the Maze, false otherwise.public Point getSize()
MazePoint describing the size of the Maze.
getSize in class MazePoint where the method getX returns the maximum X
coordintate, and the method getY returns the maximum Y coordinate.public Cell getCell(Point point)
MazeCell corresponding to a given Point in the Maze.
getCell in class Mazepoint - Location in the Maze.
Cell describing that location.public void addClient(Client client)
MazeClient at random location in the Maze.
addClient in class Mazeclient - Client to be added to the Maze.
public void addClientAtGivenPoint(Client client,
DirectedPoint directedPoint)
addClientAtGivenPoint in class Mazepublic Point getClientPoint(Client client)
MazeClient is located
in the Maze.
getClientPoint in class Mazeclient - The Client being located.
Point describing the location of the client.public Direction getClientOrientation(Client client)
MazeClient is facing.
getClientOrientation in class Mazeclient - The Client being queried.
Client as a Direction.public void removeClient(Client client)
MazeClient from the Maze
removeClient in class Mazeclient - Client to be removed.public boolean clientFire(Client client)
MazeProjectile from the specified Client
clientFire in class Mazeclient - Client that is firing.
false on failure, true on success.public boolean moveClientForward(Client client)
MazeClient in the Maze forward.
moveClientForward in class Mazeclient - Client to move.
true if successful, false if failure.public boolean moveClientBackward(Client client)
MazeClient in the Maze backward.
moveClientBackward in class Mazeclient - Client to move.
true if successful, false if failure.public java.util.Iterator getClients()
MazeIterator over all Clients in the Maze
getClients in class MazeIterator over clients in the Maze.public void addMazeListener(MazeListener ml)
Maze
addMazeListener in class Mazeml - An object implementing the MazeListener interface.public void removeMazeListener(MazeListener ml)
Maze
removeMazeListener in class Mazeml - An object implementing the MazeListener interface.
public void clientUpdate(Client c,
ClientEvent ce)
Clients in the maze.
clientUpdate in interface ClientListenerc - The Client that acted.ce - The action the Client performed.public void run()
Projectiles.
run in interface java.lang.Runnablepublic void rotateClientLeft(Client client)
Client emits a turnLeft action.
client - The Client to rotate.public void rotateClientRight(Client client)
Client emits a turnRight action.
client - The Client to rotate.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||