java.lang.Object
it.polimi.ingsw.am13.model.card.Card
All Implemented Interfaces:
CardIF, Serializable
Direct Known Subclasses:
CardObjective, CardPlayable

public abstract class Card extends Object implements CardIF
Represents a generic card of the game. It is identified by a unique id (immutable attribute), and stores other information about the card during the game. The card is present in field if all players can see it. Hence, it could be in one player's field or if it is in one of the 9 spots of the commond field. If the card is in field, visibleSide specifies what side is visible (front or back)
See Also:
  • Field Details

    • id

      private final String id
      Unique id of the card (r, g, s, o for type), number or 3 digits (in order of pdf).
    • visibleSide

      private Side visibleSide
      If the card is in the field, this specifies what side is visible. If the card is not in the field, the attribute is null
  • Constructor Details

    • Card

      Card(String id)
      Set the specified id while creating a new card The card is created not visible in the field
      Parameters:
      id - Id of the card
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface CardIF
      Returns:
      Id of the card
    • getVisibleSide

      public Side getVisibleSide()
      Specified by:
      getVisibleSide in interface CardIF
      Returns:
      The visible side of the card. If the card is not in field, returns null.
    • placeCardInField

      public void placeCardInField(Side visibleSide) throws NullPointerException
      Sets the card visible in field, with the visible side specified.
      Parameters:
      visibleSide - Visible side of the card in the field
      Throws:
      NullPointerException - if the side specified is null
    • removeCardFromField

      public void removeCardFromField()
      Removes card from field
    • 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