The Game class
An instance of the Game class contains a Row holding the secret color values and also contains a Table. When there is a new guess the Game instance stores the guess into the Table and also sets the number of positions and colors matching the secret row.
package packt.java9.by.example.mastermind;
public class Game {
final Table table;
final private Row secretRow;
boolean finished = false;
public Game(Table table, Color[] secret ) {
this.table = table;
this.secretRow = new Row(secret);
}
public void addNewGuess(Row row) {
if( isFinished()){
throw new IllegalArgumentException(
"You can not guess on a finished game.");
}
final int positionMatch = secretRow.
nrMatchingPositions(row.positions);
final int colorMatch = secretRow.
nrMatchingColors(row.positions);
row.setMatch...