Class Library

java.lang.Object
it.polimi.ingsw.model.Library
All Implemented Interfaces:
Serializable

public class Library extends Object implements Serializable
class representing each player's private library. Mutable
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
    the columns of the game library
    Card[][]
    the matrix which contains the cards placed by the user
    the name of the player using this library
    final int
    the rows of the game library
  • Constructor Summary

    Constructors
    Constructor
    Description
    copy constructor for the Library Objects, useful for deep copy
    normal constructor for this type of objects
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    checkCol(int col, int numCards)
    check if the chosen column have enough space for the cards
    int
    count the points gained thanks to adjacent cards
    void
    method that draws the library of the owner
    void
    draw(String title)
    method that draws the library of a player, not the owner
    void
    insertCards(int col, ArrayList<Card> cards)
    insert the cards in the library of the current player
    boolean
    check if the library is full
    int
    find the maximum number of cards insertable in the current library
    boolean
    check that the 2 library have the cards with the same color

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ROWS

      public final int ROWS
      the rows of the game library
      See Also:
    • COLS

      public final int COLS
      the columns of the game library
      See Also:
    • gameLibrary

      public Card[][] gameLibrary
      the matrix which contains the cards placed by the user
    • name

      public String name
      the name of the player using this library
  • Constructor Details

    • Library

      public Library(String n)
      normal constructor for this type of objects
      Parameters:
      n - the name of the player using this library
    • Library

      public Library(Library l)
      copy constructor for the Library Objects, useful for deep copy
      Parameters:
      l - the library which you need to copy
  • Method Details

    • isFull

      public boolean isFull()
      check if the library is full
      Returns:
      true or false, depending on if library is full or not
    • checkCol

      public boolean checkCol(int col, int numCards)
      check if the chosen column have enough space for the cards
      Parameters:
      col - index of column
      numCards - number of cards
      Returns:
      true iff the cards can stay inside the library column
    • maxCardsInsertable

      public int maxCardsInsertable()
      find the maximum number of cards insertable in the current library
      Returns:
      the maximum number of cards insertable in the current library (int)
    • insertCards

      public void insertCards(int col, ArrayList<Card> cards)
      insert the cards in the library of the current player
      Parameters:
      col - index of the column in which insert the cards
      cards - the cards that needs to be physically inserted in the library
    • countGroupedPoints

      public int countGroupedPoints()
      count the points gained thanks to adjacent cards
      Returns:
      the number of points made by this player
    • draw

      public void draw()
      method that draws the library of the owner
    • draw

      public void draw(String title)
      method that draws the library of a player, not the owner
    • sameLibraryColor

      public boolean sameLibraryColor(Library lib)
      check that the 2 library have the cards with the same color
      Parameters:
      lib - library that need to be checked
      Returns:
      true iff the library are equals