Class Word

java.lang.Object
model.logic.host.data.Word
All Implemented Interfaces:
Serializable

public class Word extends Object implements Serializable
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Word(Tile[] tiles, int row, int col, boolean vertical)
    The Word function is a constructor that takes in the tiles, row, column and vertical of the word.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    The allTilesAreNulls function checks to see if all the tiles in a word are null.
    boolean
    The equals function checks if two words are equal.
    int
    The getCol function returns the column of the current position.
    int
    The getRow function returns the row of the current position.
    The getTiles function returns the tiles array.
    int
    The hashCode function is used to generate a unique hash code for each object.
    boolean
    The hasNullTiles function checks to see if there are any null tiles in the array.
    boolean
    The isVertical function returns a boolean value that indicates whether the current instance of the class is vertical or not.
    void
    setTiles(Tile[] tiles)
    The setTiles function is used to set the tiles of a given board.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Word

      public Word(Tile[] tiles, int row, int col, boolean vertical)
      The Word function is a constructor that takes in the tiles, row, column and vertical of the word.
      Parameters:
      tiles - tiles Store the tiles that make up the word
      row - row Set the row of the word
      col - col Set the column of the word
      vertical - vertical Determine whether the word is vertical or horizontal
  • Method Details

    • setTiles

      public void setTiles(Tile[] tiles)
      The setTiles function is used to set the tiles of a given board.
      Parameters:
      tiles - tiles Set the tiles array to the value of temp
    • getTiles

      public Tile[] getTiles()
      The getTiles function returns the tiles array.
      Returns:
      An array of tile objects
    • getRow

      public int getRow()
      The getRow function returns the row of the current position.
      Returns:
      The row of the cell
    • getCol

      public int getCol()
      The getCol function returns the column of the current position.
      Returns:
      The column of the current position
    • isVertical

      public boolean isVertical()
      The isVertical function returns a boolean value that indicates whether the current instance of the class is vertical or not.
      Returns:
      A boolean value that indicates if the line is vertical or not
    • equals

      public boolean equals(Object o)
      The equals function checks if two words are equal.
      Overrides:
      equals in class Object
      Parameters:
      o - o Compare the current object to another object
      Returns:
      True if the two words are equal
    • hashCode

      public int hashCode()
      The hashCode function is used to generate a unique hash code for each object. This function uses the row, col, vertical and tiles fields of the WordSearchPuzzle class to generate a unique hash code for each object. The hashCode function is used in conjunction with the equals method so that two objects can be compared by their contents rather than their memory location.
      Overrides:
      hashCode in class Object
      Returns:
      A hash code value for the object
    • hasNullTiles

      public boolean hasNullTiles()
      The hasNullTiles function checks to see if there are any null tiles in the array.
      Returns:
      True if there is a null tile in the tiles array and false otherwise
    • allTilesAreNulls

      public boolean allTilesAreNulls()
      The allTilesAreNulls function checks to see if all the tiles in a word are null.
      Returns:
      True if all the tiles are nulls