O'Reilly logo

Java 9 Programming By Example by Peter Verhas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Guesser

Guesser and the UniqueGuesser and GeneralGuesser subclasses are the most interesting classes of the program. They actually perform the task that is the core of the game. Given a Table with a hidden row, the guesser has to create newer and newer guesses.

To do this, a Guesser needs to get a Table when it is created. This is passed as a constructor argument. The only method it should implement is guess, which returns a new guess based on the table and on its actual state.

As we want to implement a guesser that assumes that all colors in the hidden row are different, and also one that does not make this assumption, we will implement three classes. Guesser is an abstract class that implements only the logic that is independent from the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required