Class Spaceship

All Implemented Interfaces:
java.lang.Iterable<Block>, java.util.Iterator<Block>

public class Spaceship
extends Pattern
Represents a spaceship
  • Constructor Details

    • Spaceship

      public Spaceship​(Rule rule, Grid pattern, int period, int displacementX, int displacementY)
      Constructs a spaceship
      Parameters:
      rule - The rule the spaceship works in
      pattern - The pattern of the spaceship
      period - The period of the spaceship
      displacementX - The horizontal displacement of the spaceship
      displacementY - The vertical displacement of the spaceship
  • Method Details

    • setPhases

      public void setPhases​(Grid[] grids)
      Overrides:
      setPhases in class Pattern
    • toString

      public java.lang.String toString()
      Specified by:
      toString in class Pattern
    • additionalInfo

      public java.util.Map<java.lang.String,​java.lang.String> additionalInfo()
      Additional information about the spaceship. Namely the period, horizontal and vertical displacement and the minimum and maximum rule.
      Specified by:
      additionalInfo in class Pattern
      Returns:
      Returns a map containing the additional information about the spaceship
    • equals

      public boolean equals​(java.lang.Object o)
      Description copied from class: Grid
      Check if the inputted grid is equal to this grid (independent of translation)
      Overrides:
      equals in class Grid
      Parameters:
      o - The other grid
      Returns:
      Returns true if the grids are equal, false if they aren't
    • hashCode

      public int hashCode()
      Description copied from class: Grid
      Gets the hash of the grid.
      Overrides:
      hashCode in class Grid
      Returns:
      Returns the grid's hash (uses Golly's hash algorithm).
    • getPeriod

      public int getPeriod()
      Gets the period of the spaceship
      Returns:
      Returns the period of the spaceship
    • getDisplacementX

      public int getDisplacementX()
      Gets the displacement of the spaceship in the x-direction
      Returns:
      Returns the displacement of the spaceship in the x-direction
    • getDisplacementY

      public int getDisplacementY()
      Gets the displacement of the spaceship in the y-direction
      Returns:
      Returns the displacement of the spaceship in the y-direction
    • getPopulationSequence

      public java.util.ArrayList<java.util.ArrayList<java.lang.Integer>> getPopulationSequence()
      Gets the population sequence of the spaceship
      Returns:
      Returns the population sequence of the spaceship