|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbridge.BridgeState
public class BridgeState
This class represents states of the Bridge Crossing problem. It creates new bridge states, tests states for equality, and produces string representations of them. Note that this class implements the State interface and therefore imports framework.State. Except for the import and the class header, this class can be the same as in the previous assignment.
Constructor Summary | |
---|---|
BridgeState(Position p1Position,
Position p2Position,
Position flashlightPosition,
Position p5Position,
Position p10Position,
int timeSoFar)
Creates a new bridge state. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object other)
Compares this bridge state with another for equality. |
Position |
getFlashlightPosition()
Getter (accessor) for the position of the flashlight in this state. |
Position |
getP10Position()
Getter (accessor) for the position of person P10 in this state. |
Position |
getP1Position()
Getter (accessor) for the position of person P1 in this state. |
Position |
getP2Position()
Getter (accessor) for the position of person P2 in this state. |
Position |
getP5Position()
Getter (accessor) for the position of person P5 in this state. |
int |
getTimeSoFar()
Getter (accessor) for the time taken to get to this state. |
java.lang.String |
toString()
Creates a string representation of this state for display to the user trying to solve the problem. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BridgeState(Position p1Position, Position p2Position, Position flashlightPosition, Position p5Position, Position p10Position, int timeSoFar)
p1Position
- position of the person who can cross in 1 minutep2Position
- position of the person who can cross in 2 minutesflashlightPosition
- position of the flashlightp5Position
- position of the person who can cross in 5 minutesp10Position
- position of the person who can cross in 10 minutestimeSoFar
- time taken so farMethod Detail |
---|
public boolean equals(java.lang.Object other)
equals
in interface State
equals
in class java.lang.Object
other
- the other bridge state to be compared with this one.
public java.lang.String toString()
toString
in interface State
toString
in class java.lang.Object
public Position getFlashlightPosition()
public Position getP1Position()
public Position getP2Position()
public Position getP5Position()
public Position getP10Position()
public int getTimeSoFar()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |