org.dolben.MarkX
Class BruteForceGenerator

java.lang.Object
  extended by org.dolben.MarkN.Generator
      extended by org.dolben.MarkX.BruteForceGenerator

 class BruteForceGenerator
extends Generator

This class contains the N digit number game guess Generator that uses the Brute Force algorithm.

For each next guess it simply goes through a sequence of valid numbers to find one that could have given all of the scores that were obtained for the previous guesses.


Constructor Summary
BruteForceGenerator()
          constructs a BruteForceGenerator
 
Method Summary
static void main(java.lang.String[] arg)
          tests the class
 boolean nextGuess(Numbah guess)
          generates the next guess
 void retractScore()
          backs up to state before last nextGuess()
 void tellScore(Score score)
          is given a score for the last guess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BruteForceGenerator

BruteForceGenerator()
constructs a BruteForceGenerator

Method Detail

nextGuess

public boolean nextGuess(Numbah guess)
generates the next guess

Specified by:
nextGuess in class Generator
Parameters:
guess - the next generated guess
Returns:
true iff there is a next guess. (It won't be possible to generate a guess if scores given for the previous guesses are logically inconsistent.)

tellScore

public void tellScore(Score score)
is given a score for the last guess

Specified by:
tellScore in class Generator
Parameters:
score - the score for the last guess

retractScore

public void retractScore()
backs up to state before last nextGuess()

Specified by:
retractScore in class Generator

main

public static void main(java.lang.String[] arg)
                 throws java.lang.Exception
tests the class

Parameters:
arg - ignored
Throws:
java.lang.Exception