Class MazeTracer

java.lang.Object
  extended by MazeTracer
All Implemented Interfaces:
MazeChangeListener

public class MazeTracer
extends java.lang.Object
implements MazeChangeListener

MazeTracer implements the MazeChangeListener interface and outputs a textual trace of the progress of a MazeRunner.

Author:
Albert J. Wong (awong@cs)

Field Summary
private  java.io.PrintWriter writer
          The print writer the tracer will output its trace onto.
 
Constructor Summary
MazeTracer(java.io.PrintWriter writer)
          Creates a new MazeTracer that outputs its trace onto the PrintWriter w.
 
Method Summary
 void cellStateChangeEvent(MazeCell cell)
          This function prints out the state of the cell that has changed.
protected  void finalize()
          Ensure the writer is properly closed when this object is shutdown.
 void stateChangeEvent()
          Print outs an error if this method is called.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

writer

private java.io.PrintWriter writer
The print writer the tracer will output its trace onto.

Constructor Detail

MazeTracer

public MazeTracer(java.io.PrintWriter writer)
Creates a new MazeTracer that outputs its trace onto the PrintWriter w. Clients should in a new print writer instance because this class will close the print writer when it finishes.

Parameters:
writer - A new print writer that this object can use to output its trace onto.
Method Detail

cellStateChangeEvent

public void cellStateChangeEvent(MazeCell cell)
This function prints out the state of the cell that has changed.

Specified by:
cellStateChangeEvent in interface MazeChangeListener
Parameters:
cell - the cell whose state change is being broadcast

stateChangeEvent

public void stateChangeEvent()
Print outs an error if this method is called. This tracer only handles cell visitation state changes.

Specified by:
stateChangeEvent in interface MazeChangeListener

finalize

protected void finalize()
Ensure the writer is properly closed when this object is shutdown.

Overrides:
finalize in class java.lang.Object