Release notes version 1.0

Premises

These notes are designed for those who want not only to use the program but also for those that want study the code, perhaps to produce a new version amended.

Working

The Tower of Hanoi or Towers of Hanoi , also called the Tower of Brahma or Towers of Brahma, is a mathematical game or puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.
The program run Java's operations in background, and underline inside a TextArea, Pentium IV Assembly code line.
So there is a GUI that help users to understand with more precision what is going.


Algorithm execution is simulated step by step, so it's possible for users read messages with specific informations inside JTextArea.

It's possible continue execution pressing: testo

Code Structure

The program is structured in two classes: Esegui and Gui2.
Esegui contains main that allows you to run the program, Gui2 class manages all GUI parts of the program.



Programming Techniques

The simulation step by step is obtained by saving information in two arrays, due to the finite set on we work (Limited disks' number ).

Arrays in question are: passi[][] and testo[][], they save respectively which recursive calls is occurred instant after instant, and which Assembly lines code must be underlined on the JTextArea. Arrays are managed on mouseClicked method.
mouseClicked method manages clicks on Next button.

Columns and disks images are JLabels where there are icons that are modified when you move disks.
Next button is a JButton.
There are two JTextArea: JTextArea1 shows Assembly code, JTextArea2 shows detailed information of recursive calls.

To allow the program to run on screens with different resolutions, there are layouts that manage components resizing them. Particularly principal JFrame have a GridLayout, Panel1 and Panel2 a GridBagLayout. (Optimal resolution: 1366x768. Minimal resolution:800x600).


Components Layout

Principal JFrame components are organized through a GridLayout. Principal panel (Panel1) is composed by: JScrollPane with TextArea1 in west part, JButton in the north-center part, JScrollPane with TextArea2 in the north-east part, Panel2 in the center contains JLabels. In JPanel1 and JPanel2 components are organized by GridBagLayout.
In the JFrame where you can choose number of disks there is GridBagLayout.

Testing

The program has been tested without problems in the following SO: Windows 7 and Ubuntu 10.10

UML

asd asd
Classes
Esegui class contains a Gui2 instance, initializes it and call the following method:

1. setVisible(true) make visible principal JFrame;
Esegui class have no other methods.

Gui2 class creates graphic interface of principal frame with a JFrame, a JPanel that contains JTextArea, a JButton and
another JPanel that contains JLabels.
JLables contains images about columns and disks. Selection windows of number of disks is composed by JButtons, Info's frame by a JLabel and by a TextField.

Methods inside Gui2
1. initComponents() initializes all components above described, creating JFrame whit them.
2. info() creates info's frame callable by INFO JMenuItem .
3. sceltaG() creates frame where you can choose number of disks.
4. insertColumn() inserts number of disks choises by user, so it change JLabels icons.
5. setColonne(String,String) managed by MouseClicked() change JLabels' icons, moving disks
from a column to another, respecting recursive calls order.
6. resolve(int,int,int,String,String,String) method that solves Hanoi's problem, it save recursive call order
and which text part in JtextArea1 underline.
7. MouseCliked(MouseEvent) manage clicks on Next button, allowing to simulate Hanoi's algorithm step by step.
It underline Assembly instructions through array testo[][].
8. ActionPerformed(ActionEvent) manages clicks on JMenuItems.


Following methods are not implemented.
mouseEntered(MouseEvent )
mouseReleased(MouseEvent)
mousePressed(MouseEvent)
mouseExited(MouseEvent)

Project Code


Written and compiled with "SciTE". For Hanoi's algorithm implementation has taken cue from the book:
Strutture dati e algoritmi in Java Autor: M.T. Goodrich, R. Tamassia


Assembly Code



SOURCE: Architettura dei calcolatori - Un approccio strutturale (Andrew S. Tanenbaum).


Screenshots

Initial Situation.
asd asd
Intermediate Stage. asd asd asd asd Final Situation.


Proposed Improvements


1. More disks.
2. Using thread to stop Hanoi's algorithm, continue pressing Next button, alternatively to array.
3. Further menu implementation with more features.
4. Different components layout.


Valid HTML 4.01 Transitional