Package it.polimi.ingsw.server.model
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 voidbuildBlock()Builds 1 block more in this cellvoidbuildDome()Build the dome in the celljava.util.ArrayList<ClientViewObserver>getCellObservers()intgetLevel()WorkergetWorker()Getter method of the worker attribute of this class.intgetX()intgetY()booleanhasDome()booleanhasWorker()Finds out if in this cell there's a worker or not.booleanisInPerimeter()Finds out if the cell stays on the border of the board.booleanisOccupied()Checks if cell has a worker or a dome on it.voidmoveIn(Worker worker)States that a worker is moving in the cell.voidmoveOut()States that a worker isn't in this cell anymore.voidnotifyObservers()This method updates all the Observer of the Worker Class.voidregister(ClientViewObserver newObserver)This method adds a new Observer.voidremove(VirtualView client)Removes from the cellObservers list the client that is observing this specific cell.voidsetDome(boolean dome)voidsetLevel(int level)voidsetWorker(Worker worker)voidunregister(ClientViewObserver myObserver)This method removes an observer.
-
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
-
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
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
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
This method adds a new Observer.- Parameters:
newObserver- Reference of the observer.
-
unregister
This method removes an observer.- Parameters:
myObserver- The observer to be unregistered.
-
getCellObservers
-
notifyObservers
public void notifyObservers()This method updates all the Observer of the Worker Class. -
remove
Removes from the cellObservers list the client that is observing this specific cell.- Parameters:
client- client to be removed from observers.
-