Java Reference
In-Depth Information
public void restore(Trackable obj) {
for ( int i # 0; i < 3; i !! )
towers[i].restore( ((Hanoi)obj).towers[i] );
}
public Trackable cloneTarget() {
Hanoi clone # new Hanoi();
clone.towers[0] # new Tower();
clone.towers[1] # new Tower();
clone.towers[2] # new Tower();
clone.restore( this );
return clone;
}
}
Class Game represents the application's top level. It creates and initializes
the test application and activates the tracking process.
public class Game {
TrackingConsole console # null ;
DrawingArea drawingArea # null ;
Hanoi hanoi # null ;
public Game() {
try {
// activates the tracking process
Tracker.startTracking();
console # new TrackingConsole();
hanoi # new Hanoi();
// registers the Hanoi instance
Tracker.bind(hanoi, "hanoi");
hanoi.init();
drawingArea # new DrawingArea(hanoi);
}
catch (Exception e) { e.printStackTrace(); }
}
/**Main method*/
public static void main(String[] args) {
new Game();
}
}
Figures 18.3(a, b, c) show three snapshots of the graphical user interface
during the tracking process. The right-hand side of each image depicts the
tracking console that allows the user to save a stable state, to restore a saved
stable state, and to redo and undo single operations.
Search WWH ::




Custom Search