private void moveTopTo(StackTower t) { int top = disks.Pop(); t.add(top); Console.Out.WriteLine("Move disk " + top + " from " + Index + " to " + t.Index); }
public void moveDisks(int n, StackTower destination, StackTower buffer) { if (n > 0) { moveDisks(n - 1, buffer, destination); moveTopTo(destination); buffer.moveDisks(n - 1, destination, this); } }