Java Reference
In-Depth Information
public Integer pull() {
Tracker.record( this , "pull", null , null );
if (first ## 0)
return new Integer(0);
int size # queue[first-1];
queue[first-1] # 0;
first - ;
drawingArea.drawingPanel.repaint();
return new Integer(size);
}
public void push(Integer size) {
Tracker.record( this , "push", new Class[] {Integer.class},
new Object[] {size});
if (first ## DIM)
return ;
queue[first] # size.intValue();
first !! ;
drawingArea.drawingPanel.repaint();
}
}
The second scenario tests logical recording of complex operations, i.e.
of method move() in class Hanoi . Figure 18.5 shows the list of performed
operations.
public class Hanoi implements Trackable {
. . .
public Hanoi() { }
public void move(String from, String to) {
int f # towers[Integer.parseInt(from)].sizeOfFirst();
int t # towers[Integer.parseInt(to)].sizeOfFirst();
if (f > # t && t ! # 0)
return ;
Figure 18.5 The Tower of Hanoi after the re-execution of simple operation move()
Copyright © 2005 Sun Microsystems, Inc. All rights reserved. Reproduced by permission of Sun
Microsystems, Inc.
Search WWH ::




Custom Search