org.dolben.MarkX
Class Monitor

java.lang.Object
  extended by org.dolben.MarkX.Monitor

 class Monitor
extends java.lang.Object

A Monitor has a list of Requirements, one for each guess, and checks that a digit conforms to those Requirements, simply aggregating the effect of the individual Requirements.


Constructor Summary
Monitor(int maxGuesses)
           
 
Method Summary
 void addRequirement(Requirement requirement)
          adds a Requirement
 boolean pick(int digit, int left)
          checks that the a digit can be picked with a number of places left in the guess and informs all the Requirements of the pick when they all approve
 boolean removeRequirement()
          removes the last Requirement, for backing up when guess scoring is inconsistent
 java.lang.String toString()
          makes a string of the last Requirement
 void unpick(int digit)
          tells all of the Requirements for this Monitor to retract the pick of a digit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Monitor

Monitor(int maxGuesses)
Method Detail

addRequirement

public void addRequirement(Requirement requirement)
adds a Requirement

Parameters:
requirement - the Requirement added for the next guess

removeRequirement

public boolean removeRequirement()
removes the last Requirement, for backing up when guess scoring is inconsistent

Returns:
true iff there is a Requirement to remove

pick

public boolean pick(int digit,
                    int left)
checks that the a digit can be picked with a number of places left in the guess and informs all the Requirements of the pick when they all approve

Parameters:
digit - the digit to be checked
left - the number of places left for digits to be picked in the guess
Returns:
true iff it's OK with all of the requirements of this Monitor to pick the digit

unpick

public void unpick(int digit)
tells all of the Requirements for this Monitor to retract the pick of a digit

Parameters:
digit - the digit that is no longer picked

toString

public java.lang.String toString()
makes a string of the last Requirement

Overrides:
toString in class java.lang.Object
Returns:
a string representing the last Requirement