Omg! Towers of Hanoi. Seriously. Why isnt this right?
im doing exactly what the comments are telling me to do, but it doesnt work right.
public void recursiveTOfH( int numDisks, int fromTower, int toTower, int useTower )
// Student code starts here
// 1. Move ( numDisks - 1 ) disks from fromTower
// to useTower using toTower
// 2. Move one disk from fromTower to toTower
// Print a message to the screen, then
// call moveDisk in order to animate.
// 3. Move ( numDisks - 1 ) disks from useTower to toTower
// using fromTower
if(numDisks > 0)
recursiveTOfH(numDisks -1, fromTower, toTower, useTower);
recursiveTOfH(numDisks - 1, fromTower, useTower, toTower);
System.out.println("Move a disc from tower " + fromTower + " to tower " + toTower);
moveDisk(numDisks, fromTower, toTower);
recursiveTOfH(numDisks - 1, useTower, fromTower, toTower);
// Base case: 0 disks to move ==> do nothing
// end of student code