aima.core.environment.cellworld.Cell Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
The newest version!
package aima.core.environment.cellworld;
/**
* Artificial Intelligence A Modern Approach (3rd Edition): page 645.
*
* A representation of a Cell in the environment detailed in Figure 17.1.
*
* @param
* the content type of the cell.
*
* @author Ciaran O'Reilly
* @author Ravi Mohan
*/
public class Cell {
private int x = 1;
private int y = 1;
private C content = null;
/**
* Construct a Cell.
*
* @param x
* the x position of the cell.
* @param y
* the y position of the cell.
* @param content
* the initial content of the cell.
*/
public Cell(int x, int y, C content) {
this.x = x;
this.y = y;
this.content = content;
}
/**
*
* @return the x position of the cell.
*/
public int getX() {
return x;
}
/**
*
* @return the y position of the cell.
*/
public int getY() {
return y;
}
/**
*
* @return the content of the cell.
*/
public C getContent() {
return content;
}
/**
* Set the cell's content.
*
* @param content
* the content to be placed in the cell.
*/
public void setContent(C content) {
this.content = content;
}
@Override
public String toString() {
return "";
}
@Override
public boolean equals(Object o) {
if (o instanceof Cell) {
Cell c = (Cell) o;
return x == c.x && y == c.y && content.equals(c.content);
}
return false;
}
@Override
public int hashCode() {
return x + 23 + y + 31 * content.hashCode();
}
}