packt.java9.by.example.mastermind

## Class Row

- java.lang.Object
- - packt.java9.by.example.mastermind.Row

- Direct Known Subclasses:
    PrintableRow

      public class Row
      extends java.lang.Object

  One row on the table. It contains the guesses at position and also the number of matching colors and position.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `matchedColors`
    `protected int` | `matchedPositions`
    `static Row` | `none`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `Row(Color[] positions)`
    `protected` | `Row(Row cloneFrom)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `guessMatches(Color[] guess)`
    `int` | `nrMatchingColors(Color[] guess)` Count the number of colors that are present on the guess but not on the position where they are in the secret.
    `int` | `nrMatchingPositions(Color[] guess)` Count the number of colors that are correct and are in position.
    `int` | `nrOfColumns()`
    `void` | `setMatch(int matchedPositions, int matchedColors)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### matchedPositions

          protected int matchedPositions

    - #### matchedColors

          protected int matchedColors

    - #### none

          public static final Row none

  - ### Constructor Detail

    - #### Row

          public Row(Color[] positions)

    - #### Row

          protected Row(Row cloneFrom)

  - ### Method Detail

    - #### setMatch

          public void setMatch(int matchedPositions,
                               int matchedColors)

    - #### guessMatches

          public boolean guessMatches(Color[] guess)

    - #### nrMatchingColors

          public int nrMatchingColors(Color[] guess)

      Count the number of colors that are present on the guess but not on the position where they are in the secret. If the same color is on multiple position it is counted for each position once. For example the secret is

               RGRB

      and the guess is

               YRPR

      then this method will return 2.
      Parameters:
        `guess` - is the actual guess that we evaluate
      Returns:
        the number of good colors out of position

    - #### nrMatchingPositions

          public int nrMatchingPositions(Color[] guess)

      Count the number of colors that are correct and are in position.
      Parameters:
        `guess` - is the actual guess that we evaluate
      Returns:
        the number of colors that match in position

    - #### nrOfColumns

          public int nrOfColumns()