Source of TowersOfHanoiTest.java


  1: // Fig. 15.16: TowerOfHanoiTest.java
  2: // Test the solution to the towers of Hanoi problem.
  3: 
  4: public class TowersOfHanoiTest
  5: {
  6:    public static void main( String args[] )
  7:    {
  8:       int startPeg = 1;   // value 1 used to indicate startPeg in output
  9:       int endPeg = 3;     // value 3 used to indicate endPeg in output
 10:       int tempPeg = 2;    // value 2 used to indicate tempPeg in output
 11:       int totalDisks = 3; // number of disks
 12:       TowersOfHanoi towersOfHanoi = new TowersOfHanoi( totalDisks );
 13: 
 14:       // initial nonrecursive call: move all disks.
 15:       towersOfHanoi.solveTowers( totalDisks, startPeg, endPeg, tempPeg );
 16:    } // end main
 17: } // end class TowersOfHanoiTest
 18: 
 19: /*************************************************************************
 20: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 21: * Pearson Education, Inc. All Rights Reserved.                           *
 22: *                                                                        *
 23: * DISCLAIMER: The authors and publisher of this book have used their     *
 24: * best efforts in preparing the book. These efforts include the          *
 25: * development, research, and testing of the theories and programs        *
 26: * to determine their effectiveness. The authors and publisher make       *
 27: * no warranty of any kind, expressed or implied, with regard to these    *
 28: * programs or to the documentation contained in these books. The authors *
 29: * and publisher shall not be liable in any event for incidental or       *
 30: * consequential damages in connection with, or arising out of, the       *
 31: * furnishing, performance, or use of these programs.                     *
 32: *************************************************************************/