Free Term Papers on Towers Of Hanoi Code

OPPapers.com Essay Index >> Technology >> Towers Of Hanoi Code

We have many free term papers and essays on Towers Of Hanoi Code. We also have a wide variety of research papers and book reports available to you for free. You can browse our collection of term papers or use our search engine.

Essays from FratFiles.com
  1. Towers Of Hanoi Code

    Towers of Hanoi code /* This applet solves the Towers of Hanoi problem for a tower of 10 disks. (Ten differntly-sized disks are stacked in a pile, in order of decreasing

  2. How Important Are Mental Representations In Cognitive Theories

    model it can be programmed as a memory system, a language processor or a problem solver (e.g. the Towers Of Hanoi.). Schema theory focuses only on long term memory,

View More Papers...

Towers Of Hanoi Code

Submitted by iris_primsting on February 22, 2006

Category: Technology
Words: 3073 | Pages: 13
Views: 218
Popularity Rank: 66,115
Average Member Grade: N/A (Add a Comment / Grade this Paper)

/*
This applet solves the Towers of Hanoi problem for a tower of 10 disks.
(Ten differntly-sized disks are stacked in a pile, in order of
decreasing size. There are two other places for piles. The object
is to move the pile to the second available place, subject to the
rules that only one disk at a time can be moved, and no disk can
be piled on top of a smaller disk.) The solution is shown as
an animation. The Towers of Hanoi problem is a standard example
of recursion.

The solution is repeated over and over indefinitely.

The applet MUST have a width of 430 and a height of 143.
*/

import java.awt.*;
import java.applet.Applet;

public class TowersOfHanoi extends Applet implements Runnable {

private static Color BACKGROUND_COLOR = new Color(255,255,180);
private static Color BORDER_COLOR = new Color(100,0,0);
private static Color DISK_COLOR = new Color(0,0,180);
private static Color MOVE_DISK_COLOR = new Color(180,180,255);

private Image OSC; // The off-screen canvas.

private static final int GO = 1, SUSPEND = 2, TERMINATE = 3; // Values for status.

private int status = GO; // Controls the execution of the thread.

private Thread runner; // A thread to run the animation.

/* The following variables are the data needed for the animation. The
three "piles" of disks are represented by the variables tower and
towerHeight. towerHeight[i] is the number of disks on pile number i.
For i=0,1,2 and for j=0,1,...,towerHeight[i]-1, tower[i][j] is an integer
representing one of the ten disks. (The disks are numbered from 1 to 10.)
(tower is null...

You must Login to view the entire paper.
If you are not a member yet, Sign Up for free!