|
||||||||||
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 Client s 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 Client s 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 Projectile s. |
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.IOException
public void print()
public boolean checkBounds(Point point)
Maze
Point
is within the bounds of the Maze
.
checkBounds
in class Maze
true
if the point lies within the Maze
, false
otherwise.public Point getSize()
Maze
Point
describing the size of the Maze
.
getSize
in class Maze
Point
where the method getX
returns the maximum X
coordintate, and the method getY
returns the maximum Y coordinate.public Cell getCell(Point point)
Maze
Cell
corresponding to a given Point
in the Maze
.
getCell
in class Maze
point
- Location in the Maze
.
Cell
describing that location.public void addClient(Client client)
Maze
Client
at random location in the Maze
.
addClient
in class Maze
client
- Client
to be added to the Maze
.public void addClientAtGivenPoint(Client client, DirectedPoint directedPoint)
addClientAtGivenPoint
in class Maze
public Point getClientPoint(Client client)
Maze
Client
is located
in the Maze
.
getClientPoint
in class Maze
client
- The Client
being located.
Point
describing the location of the client.public Direction getClientOrientation(Client client)
Maze
Client
is facing.
getClientOrientation
in class Maze
client
- The Client
being queried.
Client
as a Direction
.public void removeClient(Client client)
Maze
Client
from the Maze
removeClient
in class Maze
client
- Client
to be removed.public boolean clientFire(Client client)
Maze
Projectile
from the specified Client
clientFire
in class Maze
client
- Client
that is firing.
false
on failure, true
on success.public boolean moveClientForward(Client client)
Maze
Client
in the Maze
forward.
moveClientForward
in class Maze
client
- Client
to move.
true
if successful, false
if failure.public boolean moveClientBackward(Client client)
Maze
Client
in the Maze
backward.
moveClientBackward
in class Maze
client
- Client
to move.
true
if successful, false if failure.public java.util.Iterator getClients()
Maze
Iterator
over all Client
s in the Maze
getClients
in class Maze
Iterator
over clients in the Maze
.public void addMazeListener(MazeListener ml)
Maze
addMazeListener
in class Maze
ml
- An object implementing the MazeListener
interface.public void removeMazeListener(MazeListener ml)
Maze
removeMazeListener
in class Maze
ml
- An object implementing the MazeListener
interface.public void clientUpdate(Client c, ClientEvent ce)
Client
s in the maze.
clientUpdate
in interface ClientListener
c
- The Client
that acted.ce
- The action the Client
performed.public void run()
Projectile
s.
run
in interface java.lang.Runnable
public 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 |