|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
javax.swing.JApplet
net.pacbell.jfai.toh.util.AbstractJMainFrame
net.pacbell.jfai.toh.TowerOfHanoi
public class TowerOfHanoi
This class is the entry point to solve and visualize the "Tower Of Hanoi" puzzle.
There is a base with three pins to accept disks. Each disk has a certain size. At the beginning all disks are stacked on one pin. The goal is to move the stack to another empty pin.
Legal moves:
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JApplet |
|---|
JApplet.AccessibleJApplet |
| Nested classes/interfaces inherited from class java.applet.Applet |
|---|
Applet.AccessibleApplet |
| Nested classes/interfaces inherited from class java.awt.Panel |
|---|
Panel.AccessibleAWTPanel |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| Fields inherited from class net.pacbell.jfai.toh.util.AbstractJMainFrame |
|---|
ARGUMENT_HEIGHT, ARGUMENT_WIDTH |
| Fields inherited from class javax.swing.JApplet |
|---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
TowerOfHanoi()
Create an instance for use in an applet. |
|
TowerOfHanoi(String[] args)
Create an instance for use in a stand-alone application. |
|
| Method Summary | |
|---|---|
protected void |
buildContentPane(Container contentPane)
(Application and Applet) Constructs the contents of the given content pane of a root container. |
void |
destroy()
Applet destruction: clean up. |
Solver |
getSolver()
Gets the solver. |
TowerOfHanoiView |
getView()
Gets the view. |
protected void |
initialize(String[] args)
(Application and Applet) Parses the given arguments. Attempts to detect if the Java 3D classes are missing (by checking for Tuple3f) and if so, creates a text
component with an error message. |
static void |
main(String[] args)
Allows this class to be invoked as a Java application. |
String |
usageMessage()
Answer a String describing how to invoke the application correctly. |
| Methods inherited from class net.pacbell.jfai.toh.util.AbstractJMainFrame |
|---|
addListeners, buildWindow, getArgument, getArgument, getErrorComponent, hasErrorComponent, init, parseArguments, parseHeightArgument, parseWidthArgument, resize, setErrorComponent, usage, usage, windowTitle |
| Methods inherited from class javax.swing.JApplet |
|---|
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update |
| Methods inherited from class java.applet.Applet |
|---|
getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop |
| Methods inherited from class java.awt.Panel |
|---|
addNotify |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TowerOfHanoi()
public TowerOfHanoi(String[] args)
Accept these arguments:
size: the number of disks of the initial tower.
Default is 4.from: the pin to put the initial tower at. Default
is 'left'.to: the pin to move the tower to. Default is
'right'. Valid values for from and to are: 'left', 'middle', 'right'.
Sample invocation: TowerOfHanoi size=4 from=left to=right
args - The arguments found during invocation.| Method Detail |
|---|
public static void main(String[] args)
args - The arguments found during invocation.public void destroy()
destroy in class Appletpublic Solver getSolver()
public TowerOfHanoiView getView()
public String usageMessage()
usageMessage in class AbstractJMainFrameprotected void buildContentPane(Container contentPane)
buildContentPane in class AbstractJMainFramecontentPane - the content pane of a containerAbstractJMainFrame.buildContentPane(java.awt.Container)protected void initialize(String[] args)
Tuple3f) and if so, creates a text
component with an error message. The text displays instead of the
regular view.
initialize in class AbstractJMainFrameargs - The invocation arguments. If args parameter is null, then
the instance is an applet.AbstractJMainFrame.initialize(java.lang.String[]),
AbstractJMainFrame.setErrorComponent(java.awt.Component)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||