All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class cs101.tower.TowerHanoi

java.lang.Object
   |
   +----cs101.tower.TowerHanoi

public class TowerHanoi
extends Object
Sets up a graphical Towers of Hanoi problem by
creating a window using the CS101Canvas class and
adding 3 poles and the appropriate number of discs
on the first pole.


Constructor Index

 o TowerHanoi(int)
Constructs the window.
 o TowerHanoi(int, boolean)
Constructs the window with verbose support.

Method Index

 o move(int, int)
Moves a disk from one pole to another.
 o setAnimation(boolean)
Turns animation on or off.

Constructors

 o TowerHanoi
 public TowerHanoi(int discNum)
Constructs the window.
Note: At least 3 discs must be created with a max of 10

Parameters:
discNum - number of discs
Returns:
none
 o TowerHanoi
 public TowerHanoi(int discNum,
                   boolean value)
Constructs the window with verbose support.

Parameters:
discNum - number of discs
value - boolean value to set verbose
See Also:
move

Methods

 o setAnimation
 public void setAnimation(boolean animate)
Turns animation on or off. (Default is on.)

Parameters:
animate - true if animation is desired
 o move
 public void move(int from,
                  int to)
Moves a disk from one pole to another. The program
will be terminated if a invalide pole number is passed.

Parameters:
from - pole to move disk from (1-3)
to - pole to move disk to (1-3)
Returns:
none

All Packages  Class Hierarchy  This Package  Previous  Next  Index