April 2017
Beginner
504 pages
14h 11m
English
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 ...Read now
Unlock full access