Class Cell

java.lang.Object
it.polimi.ingsw.server.model.Cell

public class Cell
extends java.lang.Object
This class represents a board's cell structure. It contains the info about the height of the building in this specific position of the board, which is defined thanks to precise Cartesian attributes, and then if there is a worker standing in this position at a certain point of the game.
  • Constructor Summary

    Constructors 
    Constructor Description
    Cell​(int x, int y)  
  • Method Summary

    Modifier and Type Method Description
    void buildBlock()
    Builds 1 block more in this cell
    void buildDome()
    Build the dome in the cell
    java.util.ArrayList<ClientViewObserver> getCellObservers()  
    int getLevel()  
    Worker getWorker()
    Getter method of the worker attribute of this class.
    int getX()  
    int getY()  
    boolean hasDome()  
    boolean hasWorker()
    Finds out if in this cell there's a worker or not.
    boolean isInPerimeter()
    Finds out if the cell stays on the border of the board.
    boolean isOccupied()
    Checks if cell has a worker or a dome on it.
    void moveIn​(Worker worker)
    States that a worker is moving in the cell.
    void moveOut()
    States that a worker isn't in this cell anymore.
    void notifyObservers()
    This method updates all the Observer of the Worker Class.
    void register​(ClientViewObserver newObserver)
    This method adds a new Observer.
    void remove​(VirtualView client)
    Removes from the cellObservers list the client that is observing this specific cell.
    void setDome​(boolean dome)  
    void setLevel​(int level)  
    void setWorker​(Worker worker)  
    void unregister​(ClientViewObserver myObserver)
    This method removes an observer.

    Methods inherited from class java.lang.Object

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

    • Cell

      public Cell​(int x, int y)
  • Method Details

    • getLevel

      public int getLevel()
    • setLevel

      public void setLevel​(int level)
    • setDome

      public void setDome​(boolean dome)
    • setWorker

      public void setWorker​(Worker worker)
    • hasDome

      public boolean hasDome()
    • buildBlock

      public void buildBlock()
      Builds 1 block more in this cell
    • buildDome

      public void buildDome()
      Build the dome in the cell
    • hasWorker

      public boolean hasWorker()
      Finds out if in this cell there's a worker or not.
      Returns:
      true if the cell contains a worker
    • moveIn

      public void moveIn​(Worker worker)
      States that a worker is moving in the cell.
      Parameters:
      worker - Is the worker arriving in the cell
    • moveOut

      public void moveOut()
      States that a worker isn't in this cell anymore.
    • isInPerimeter

      public boolean isInPerimeter()
      Finds out if the cell stays on the border of the board.
      Returns:
      true if the cell is on the border of the board
    • isOccupied

      public boolean isOccupied()
      Checks if cell has a worker or a dome on it.
      Returns:
      true if is occupied, otherwise false.
    • getWorker

      public Worker getWorker()
      Getter method of the worker attribute of this class.
      Returns:
      The specific worker that stands inside this cell, null if there's no one.
    • getX

      public int getX()
    • getY

      public int getY()
    • register

      public void register​(ClientViewObserver newObserver)
      This method adds a new Observer.
      Parameters:
      newObserver - Reference of the observer.
    • unregister

      public void unregister​(ClientViewObserver myObserver)
      This method removes an observer.
      Parameters:
      myObserver - The observer to be unregistered.
    • getCellObservers

      public java.util.ArrayList<ClientViewObserver> getCellObservers()
    • notifyObservers

      public void notifyObservers()
      This method updates all the Observer of the Worker Class.
    • remove

      public void remove​(VirtualView client)
      Removes from the cellObservers list the client that is observing this specific cell.
      Parameters:
      client - client to be removed from observers.