public class HanoiState
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
HanoiState.Listener
Permet d'être notifié des changements d'états
(utilisé p.ex. par la fenêtre d'affichage)
|
Modifier and Type | Field and Description |
---|---|
static int |
MAX_DISKS
Nombre max. de pièces
|
static int |
NUM_TOWERS
Nombre de tours
|
Constructor and Description |
---|
HanoiState(int n)
Construit un jeu des Tours de Hanoï à n disques
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(HanoiState.Listener l)
Enregistre un listener supplémentaire
|
int |
getDiskSize(int tower,
int j)
Retourne la taille de la pièce en position j de la tour i
|
int |
getMovesCount()
Retourne le nombre total de déplacements
|
int |
getNumDisks(int tower)
Retourne le nombre de pièces sur la tour i
|
void |
move(int from,
int to)
Déplace une pièce du sommet d'une tour au sommet d'une autre tour.
|
public static final int NUM_TOWERS
public static final int MAX_DISKS
public HanoiState(int n)
n
- Le nombre de disquespublic void move(int from, int to)
from
- Indice de la tours de départto
- Indice de la tour d'arrivéepublic int getNumDisks(int tower)
tower
- L'indice de la tourpublic int getDiskSize(int tower, int j)
tower
- L'indice de la tourj
- La position de la piècepublic int getMovesCount()
public void addListener(HanoiState.Listener l)