|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jeops.examples.hanoi.Hanoi
This class models an encapsulation for a solution for the Towers of Hanoi problem.
Constructor Summary | |
Hanoi(int numDiscs,
int source,
int destination)
Class constructor. |
Method Summary | |
void |
addMove(int from,
int to)
Adds a movement to the solution. |
void |
dump()
Prints the tree for the expression of this precondition. |
void |
dump(int spaces)
Prints the tree for the expression of this precondition. |
int |
getDestination()
Returns the destination pin for this problem. |
int |
getDiscs()
Returns the number of discs of this problem. |
int |
getIntermediate()
Returns the intermediate pin form this problem. |
boolean |
getOk()
Returns the state of this problem. |
int |
getSource()
Returns the source pin for this problem. |
Hanoi |
getSub1()
Returns the first subproblem for this problem. |
Hanoi |
getSub2()
Returns the second subproblem for this problem. |
void |
setOk(boolean newValue)
Determines whether this problem has already been solved. |
void |
setSub1(Hanoi sub1)
Determines the first subproblem for this problem. |
void |
setSub2(Hanoi sub2)
Determines the second subproblem for this problem. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public Hanoi(int numDiscs, int source, int destination)
numDiscs
- the number of the discs for this instance.source
- the source pindestination
- the destination pinMethod Detail |
public void addMove(int from, int to)
from
- the pin from where the disc is moved.to
- the pin to where the disc is moved.public void dump()
public void dump(int spaces)
spaces
- the identation for the printed output.public int getDestination()
public int getDiscs()
public int getIntermediate()
public boolean getOk()
true
if this problem has already been
solved; false
otherwise.public int getSource()
public Hanoi getSub1()
public Hanoi getSub2()
public void setOk(boolean newValue)
newValue
- the new value for the state of this problem.public void setSub1(Hanoi sub1)
sub1
- the new value for the first subproblem of this one.public void setSub2(Hanoi sub2)
sub1
- the new value for the second subproblem of this one.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |