*** The Towers of Hanoi ***
The Legend:
In a remote mountain monastery, there existed a set of three diamond needles. Stacked
on the first diamond needle were 64 gold disks of decreasing size. The monks of this
monastery would move one disk to another needle each hour, subjet to two rules:
- Only one disk could be moved at a time
- A larger disk must never be stacked above a smaller disk
It was believed that when all 64 disks had been transferred to the third needle according
to these rules, the stars would be extinguished and the world would end.
The Rules:
Clicking on a tower with the mouse will "pick up" the top disk on that tower. You can then
drag the disk to another tower and place it by releasing the mouse button. All moves must be
made according to the rules described in the above legend. If you attempt to place a disk
in a way that violates the rules, the disk will return to its tower of origin.
Implementation and Features:
This applet was implemented in two parts: The first,
HTower.java
, is a class which encapsulates all of the mechanics and asthetics of a single "tower." The
second part,
Towers2.java
, is the actual applet. It loads the puzzle's graphic images, creates and manages three
instances of the "HTower" class, handles all user input, and monitors the progress of the
game.
The Puzzle: