package hanoi; public class Hanoi1 { /* Recursive procedure to move the disk at a height from one pin to another pin using a third pin. */ private void moveTower(int height, int fromPin, int toPin, int usingPin) { if (height > 0) { moveTower(height-1, fromPin, usingPin, toPin); moveDisk(fromPin, toPin); moveTower(height-1, usingPin, toPin, fromPin); } } /* Move a disk from a pin to another pin. Print the results in the console window. */ private void moveDisk(int fromPin, int toPin) { System.out.println(fromPin + " -> " + toPin); } /* Main: Create the object and invoke the moveTower method. */ public static void main(String args[]) { (new Hanoi1()).moveTower(3, 1, 3, 2); } }