Interface GameMatrix

All Known Subinterfaces:
Riddle

public interface GameMatrix
The quadratic matrix of a game field.
Author:
Stephan Fuhrmann
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canSet(int row, int column, byte value)
    Checks if the effect of one set operation is valid.
    void
    Clear the cells.
    byte
    get(int row, int column)
    Get the value of a field.
    byte[][]
    Gets a copy of the underlying array.
    Get the game schema that defines the dimensions of this matrix.
    int
    Get the number of set cells.
    boolean
    Checks if the whole play field is valid.
    void
    set(int row, int column, byte value)
    Set the value of a field.
    void
    setAll(byte[][] initializationData)
    Sets all cells to the given values.
  • Method Details

    • getSchema

      GameSchema getSchema()
      Get the game schema that defines the dimensions of this matrix.
      Returns:
      the game schema that was used to initialize this matrix.
    • clear

      void clear()
      Clear the cells.
    • get

      byte get(int row, int column)
      Get the value of a field.
      Parameters:
      row - the row of the cell to get the value for.
      column - the column of the cell to get the value for.
      Returns:
      the cell value ranging from 0 to 9.
    • set

      void set(int row, int column, byte value)
      Set the value of a field.
      Parameters:
      column - the column of the field.
      row - the row of the field.
      value - the value of the field.
    • setAll

      void setAll(byte[][] initializationData)
      Sets all cells to the given values.
      Parameters:
      initializationData - initialization data with the first dimension being the rows and the second dimension being the columns.
    • getSetCount

      int getSetCount()
      Get the number of set cells.
      Returns:
      the number of fields with a number in. Can be in the range between 0 and 81.
    • getArray

      byte[][] getArray()
      Gets a copy of the underlying array.
      Returns:
      the data array containing numbers between 0 and 9. The first index is the row index, the second index is the column index.
    • isValid

      boolean isValid()
      Checks if the whole play field is valid.
      Returns:
      true if the filled rows, columns and blocks contain no duplicate numbers.
    • canSet

      boolean canSet(int row, int column, byte value)
      Checks if the effect of one set operation is valid. This is much quicker than isValid().
      Parameters:
      row - the row of the cell to test validity for.
      column - the column of the cell to test validity for.
      value - the value to simulate setting for.
      Returns:
      true if the given cell can be set to value without violating the game rules.