|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectSearchNode
BucketsNode
public class BucketsNode
BucketsNode.java - Search node for buckets puzzle. Problem: Given a 5 unit and a 3 unit bucket, how can one measure precisely 4 units? Possible operations: fill/empty 1st/2nd bucket or pour contents of one to the other until source empty or recipient is full.
| Field Summary | |
|---|---|
int |
bucket1
variable bucket1 - amount in first bucket |
int |
bucket2
variable bucket2 - amount in second bucket |
int |
MAX_AMOUNT1
variable MAX_AMOUNT1 - max amount in first bucket |
int |
MAX_AMOUNT2
variable MAX_AMOUNT2 - max amount in second bucket |
| Fields inherited from class SearchNode |
|---|
parent |
| Constructor Summary | |
|---|---|
BucketsNode()
Creates a BucketsNode instance and sets it
to an initial search state. |
|
| Method Summary | |
|---|---|
boolean |
equals(java.lang.Object o)
equals - whether or not two BucketsNode objects
have the same state. |
java.util.ArrayList<SearchNode> |
expand()
expand - return an ArrayList |
boolean |
isGoal()
isGoal - test whether or not the current node is a
goal node. |
java.lang.String |
toString()
toString - string representation of state |
| Methods inherited from class SearchNode |
|---|
childClone, clone |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public int bucket1
bucket1 - amount in first bucket
public int bucket2
bucket2 - amount in second bucket
public final int MAX_AMOUNT1
MAX_AMOUNT1 - max amount in first bucket
public final int MAX_AMOUNT2
MAX_AMOUNT2 - max amount in second bucket
| Constructor Detail |
|---|
public BucketsNode()
BucketsNode instance and sets it
to an initial search state.
| Method Detail |
|---|
public boolean isGoal()
isGoal - test whether or not the current node is a
goal node.
isGoal in class SearchNodeboolean valuepublic java.util.ArrayList<SearchNode> expand()
expand - return an ArrayList
expand in class SearchNodeArrayList of SearchNodespublic boolean equals(java.lang.Object o)
equals - whether or not two BucketsNode objects
have the same state.
equals in class java.lang.Objecto - an Object value - object to test for
equality with this
boolean value - whether or not two
objects are equalpublic java.lang.String toString()
toString - string representation of state
toString in class java.lang.ObjectString value
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||