model
Class Cell

java.lang.Object
  extended by model.Cell

public class Cell
extends java.lang.Object

ADT Cell which depicts a square, one of the 64 in a chessboard.


Constructor Summary
Cell(int x, int y)
          constructor: Creates a new Cell with the given coordinates.
Cell(int x, int y, java.awt.Color z, Piece r)
          constructor: Creates a new Cell with the given coordinates, the given color, and places a Piece on that Cell.
 
Method Summary
 boolean equals(java.lang.Object other)
          accessor(observer): Checks if two cells are equals, if they correspond to the same coordinates.
 java.awt.Color getColor()
          accessor(selector): Returns the Color of a Cell.
 Piece getPiece()
          accessor(selector): Returns the Piece from the specific Cell.
 int getX()
          accessor(selector): Returns the Cell's ordinate.
 int getY()
          accessor(selector): Returns the Cell's abscissa.
 int hashCode()
          accessor(selector): Returns the hash code of the given Cell.
 void setColor(java.awt.Color z)
          transformer(mutative): Sets the Cell's Color to the parameter passed by.
 void setPiece(Piece x)
          transformer(mutative): Changes the Cell's Piece to the one passed as parameter.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cell

public Cell(int x,
            int y)
     throws IllegalCellException
constructor: Creates a new Cell with the given coordinates.
precondition: x and y must be valid coordinates, meaning they must be between 0 and 7.
postcondition: Creates a new Cell with the given coordinates if valid.

Parameters:
x - The ordinate of the new Cell
y - The abscissa of the new Cell
Throws:
java.lang.IllegalArgumentException - if x or y are invalid coordinates
IllegalCellException

Cell

public Cell(int x,
            int y,
            java.awt.Color z,
            Piece r)
     throws IllegalCellException
constructor: Creates a new Cell with the given coordinates, the given color, and places a Piece on that Cell.
precondition: x and y must be between 0 and 7.
postcondition: Creates a new Cell with the characteristics provided by the parameters.

Parameters:
x - Ordinate of the new Cell
y - Abscissa of the new Cell
z - Color of the new Cell
r - Piece placed on the new Cell
Throws:
java.lang.IllegalArgumentException - if x or y are not valid coordinates
IllegalCellException
Method Detail

getColor

public java.awt.Color getColor()
accessor(selector): Returns the Color of a Cell.
postcondition: Returns the Color of this Cell.

Returns:
the Color of this Cell

setColor

public void setColor(java.awt.Color z)
transformer(mutative): Sets the Cell's Color to the parameter passed by.
postcondition: Changes the Cell's Color to the one passed by.

Parameters:
z - Color to change the Cell.

getPiece

public Piece getPiece()
accessor(selector): Returns the Piece from the specific Cell.
postcondition: Returns the Piece from the specific Cell if there is one, if there is no Piece, null is returned.

Returns:
a Piece from the Cell it was called upon.

setPiece

public void setPiece(Piece x)
transformer(mutative): Changes the Cell's Piece to the one passed as parameter.
postcondition: Alters the Cell's Piece to the parameter one.

Parameters:
x - Piece to be placed on the Cell

getX

public int getX()
accessor(selector): Returns the Cell's ordinate.
postcondition: Returns the Cell's ordinate.

Returns:
an integer to point the Cell's ordinate

getY

public int getY()
accessor(selector): Returns the Cell's abscissa.
postcondition: Return's the Cell's abscissa.

Returns:
an integer to point the Cell's abscissa

equals

public boolean equals(java.lang.Object other)
accessor(observer): Checks if two cells are equals, if they correspond to the same coordinates.
precondition: other must be an instance of Cell and must no be null.
postcondition: Given an Object returns true if other is an instance of Cell and has the same coordinates with the (this) Cell. Otherwise returns false.

Overrides:
equals in class java.lang.Object
Parameters:
other - Other Cell to check equality
Returns:
true if this and other Cell are equals, false otherwise.

hashCode

public int hashCode()
accessor(selector): Returns the hash code of the given Cell.
postcondition: Returns the hash code of the given Cell, if two Cell(s) are equal(with the equals method) they must return the same hash code.

Overrides:
hashCode in class java.lang.Object