Programmieren_Projekt/visualizationElements/Cell.java

179 lines
3.6 KiB
Java
Raw Normal View History

package visualizationElements;
/**
* Represents a Cell of a maze.
* @author MSchaefer
*
*/
public class Cell {
private boolean northWall = true;
private boolean southWall = true;
private boolean westWall = true;
private boolean eastWall = true;
private boolean isStart;
private boolean isGoal;
private boolean visited;
private final int column;
private final int row;
/**
* Creates a new cell of a maze.
* @param column Number of the column the cell is arranged in.
* @param row Number of the row the cell is arranged in.
*/
public Cell(int column, int row){
this.column = column;
this.row = row;
}
/**
* Sets the cell's north wall to false.
*/
public void removeNorthWall(){
this.northWall = false;
}
/**
* Sets the cell's south wall to false.
*/
public void removeSouthWall(){
this.southWall = false;
}
/**
* Sets the cell's west wall to false.
*/
public void removeWestWall(){
this.westWall = false;
}
/**
* Sets the cell's east wall to false.
*/
public void removeEastWall(){
this.eastWall = false;
}
/**
* @param northWall the northWall to set
*/
public void setNorthWall(boolean northWall) {
this.northWall = northWall;
}
/**
* Returns whether the cell has a north wall or not.
* @return True if the cell has a north wall, false otherwise.
*/
public boolean hasNorthWall(){
return northWall;
}
/**
* @param southWall the southWall to set
*/
public void setSouthWall(boolean southWall) {
this.southWall = southWall;
}
/**
* Returns whether the cell has a south wall or not.
* @return True if the cell has a south wall, false otherwise.
*/
public boolean hasSouthWall(){
return southWall;
}
/**
* @param westWall the westWall to set
*/
public void setWestWall(boolean westWall) {
this.westWall = westWall;
}
/**
* Returns whether the cell has a west wall or not.
* @return True if the cell has a west wall, false otherwise.
*/
public boolean hasWestWall(){
return westWall;
}
/**
* @param eastWall the eastWall to set
*/
public void setEastWall(boolean eastWall) {
this.eastWall = eastWall;
}
/**
* Returns whether the cell has a east wall or not.
* @return True if the cell has a east wall, false otherwise.
*/
public boolean hasEastWall(){
return eastWall;
}
/**
* Sets the cell as visited.
*/
public void markAsVisited() {
this.visited = true;
}
/**
* Returns whether the cell was visited or not.
* @return True if the cell was visited, false otherwise.
*/
public boolean isVisited() {
return visited;
}
/**
* Sets the cell as the goal of the maze.
*/
public void setAsGoal() {
this.isGoal = true;
}
/**
* Returns whether the cell is the goal of the maze it contains to.
* @return True if the cell is the goal of the maze, false otherwise.
*/
public boolean isGoal() {
return isGoal;
}
/**
* Returns the row number.
* @return the number of the row the cell is arranged to.
*/
public int getRow() {
return row;
}
/**
* Returns the column number.
* @return the number of the column the cell is arranged to.
*/
public int getColumn() {
return column;
}
/**
* Sets the cell as the start cell of the maze it contains to.
*/
public void setAsStart() {
this.isStart = true;
}
/**
* Returns whether the cell is the start of the maze it contains to.
* @return True if the cell is the start cell of the maze, false otherwise.
*/
public boolean isStart() {
return isStart;
}
}