Package zebra4j

Class BasicPuzzle

java.lang.Object
zebra4j.BasicPuzzle

public final class BasicPuzzle extends Object
A puzzle that asks all attributes in getAttributeSets() to be assigned to people, satisfying rules defined by the attribute sets used in the puzzle (e.g. all people have different name and the name may be Liza, John or Mary). The assignment must also satisfy the given set of Facts.

The puzzle is immutable if the provided input collections are immutable.

For efficiency, the puzzle constructor does not validate if the attribute sets and facts are consistent. Use PuzzleBuilder is validation is preferred.

  • Constructor Details

  • Method Details

    • numPeople

      public int numPeople()
      Returns:
      the number of people in the puzzle
    • contains

      public boolean contains(Attribute attr)
      Parameters:
      attr - required
      Returns:
      if the puzzle refers to the given attribute
    • describeConstraints

      public List<String> describeConstraints(Locale locale)
      Describe in natural language the constraints that the solution must satisfy.
      Parameters:
      locale - required
      Returns:
      a list of sentences in the given locale, not null.
    • getAttributeSets

      public Map<AttributeType,​Set<Attribute>> getAttributeSets()
      The attribute types and the sub-sets of their values used in the puzzle.
    • getFacts

      public Collection<Fact> getFacts()
      The facts that must be satisfied by any solution of the puzzle.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object