Class Slot

java.lang.Object
it.polimi.ingsw.gc14.Model.Slot
All Implemented Interfaces:
Serializable

public class Slot extends Object implements Serializable
Represents a slot with a specific identifier and associated values for upper cards, lower cards, food, and minimum number of players. The slot configuration depends on the specified slot identifier.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    The amount of Food associated with this slot.
    private final int
    The number of lower cards associated with this slot.
    private int
    The minimum number of players required for this slot.
    private final int
    The number of upper cards associated with this slot.
    private final char
    The identifier of this slot.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Slot(char slotId)
    Creates a slot with the specified identifier.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks equality between this Slot and another object.
    int
    Returns the amount of Food associated with this slot.
    int
    Returns the number of lower cards associated with this slot.
    int
    Returns the minimum number of players required for this slot.
    int
    Returns the number of upper cards associated with this slot.
    char
    Returns the identifier of this slot.
    int
    Returns the hash code for this Slot, derived from slotId.
    Returns the string representation of this slot.
    Returns a compact string representation of this Slot for the TUI.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • slotId

      private final char slotId
      The identifier of this slot.
    • nUpper

      private final int nUpper
      The number of upper cards associated with this slot.
    • nMinPlayer

      private int nMinPlayer
      The minimum number of players required for this slot.
    • nLower

      private final int nLower
      The number of lower cards associated with this slot.
    • food

      private final int food
      The amount of Food associated with this slot.
  • Constructor Details

    • Slot

      public Slot(char slotId) throws IllegalArgumentException
      Creates a slot with the specified identifier. The slot values for Food, NLower, NUpper, and minimum number of players are determined by the given slot identifier.
      Parameters:
      slotId - the identifier of the slot.
      Throws:
      IllegalArgumentException - if the specified slot identifier is not valid.
  • Method Details

    • getSlotId

      public char getSlotId()
      Returns the identifier of this slot.
      Returns:
      the identifier of this slot.
    • getNUpper

      public int getNUpper()
      Returns the number of upper cards associated with this slot.
      Returns:
      the number of upper cards associated with this slot.
    • getNMinPlayer

      public int getNMinPlayer()
      Returns the minimum number of players required for this slot.
      Returns:
      the minimum number of players required for this slot.
    • getNLower

      public int getNLower()
      Returns the number of lower cards associated with this slot.
      Returns:
      the number of lower cards associated with this slot.
    • getFood

      public int getFood()
      Returns the amount of Food associated with this slot.
      Returns:
      the amount of Food associated with this slot.
    • toString

      public String toString()
      Returns the string representation of this slot. The returned string includes the slot identifier, number of upper cards, number of lower cards, food value, and minimum number of players.
      Overrides:
      toString in class Object
      Returns:
      the string representation of this slot.
    • toStringTUI

      public String toStringTUI()
      Returns a compact string representation of this Slot for the TUI.

      Includes:

      Returns:
      a compact TUI string representation of this Slot.
      See Also:
    • equals

      public boolean equals(Object obj)
      Checks equality between this Slot and another object. Two slots are equal if and only if they share the same slotId.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare with.
      Returns:
      true if obj is a Slot with the same identifier; false otherwise.
    • hashCode

      public int hashCode()
      Returns the hash code for this Slot, derived from slotId.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code of the slot identifier.