bridge
Class BridgeProblem

java.lang.Object
  extended by framework.Problem
      extended by bridge.BridgeProblem

public class BridgeProblem
extends Problem

This class represents the Bridge Crossing problem. It provides an introductory message describing the problem, stores the problem's possible moves and current state, and checks for whether the problem has been successfully solved. Note that this class extends the abstract class Problem and therefore imports framework.Problem. This class inherits the setIntroduction(), setCurrentState(), and setMoves() methods from its parent and thus it should not have any instance fields for these attributes.


Constructor Summary
BridgeProblem()
          Constructs a new bridge problem object.
 
Method Summary
 boolean success()
          Returns whether the current state of this problem is a success.
 
Methods inherited from class framework.Problem
getCurrentState, getIntroduction, getMoves, setCurrentState, setIntroduction, setMoves
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BridgeProblem

public BridgeProblem()
Constructs a new bridge problem object. A new bridge state object should be constructed with P1, P2, P5, P10, and the flashlight all on the west side of the bridge with zero time elapsed. This state should be set as the current state of the problem using the inherited setCurrentState() method. The ten valid bridge moves should be created and stored on a list using the inherited setMoves() method. The appropriate introduction string for this problem should be stored using the inherited setIntroduction().

Method Detail

success

public boolean success()
Returns whether the current state of this problem is a success. Note that this method implements the abstract success method declared in the parent. Note also that the current state of the problem must be gotten using the inherited getCurrentState() method. Since that method returns a value of type State, it must be cast to BridgeState before processing. The current state is a success if P1, P2, P5, and P10 are all on the east side of the bridge and the time taken to cross is less than 18 minutes.

Specified by:
success in class Problem
Returns:
true if the current state is a success, false otherwise