Coverage Summary for Class: DFSHelper (it.polimi.ingsw.model)
Class |
Class, %
|
Method, %
|
Line, %
|
DFSHelper |
100%
(1/1)
|
100%
(4/4)
|
100%
(8/8)
|
package it.polimi.ingsw.model;
/**
* helper class for the Depth First Search algorithm. Immutable
* @author Ettori Faccincani
*
*/
public class DFSHelper {
private static final int ROWS = 6;
private static final int COLS = 5;
/**
* standard constructor, only for testing purpose
* @author Ettori
*/
public DFSHelper(){}
/**
* reset the matrix of the nodes visited in the DFS
* @param mat the matrix
* @author Ettori Giammusso
*/
public static void resetVisitedMatrix(int[][] mat) {
for (int i = 0; i < ROWS; i++) {
for (int j = 0; j < COLS; j++) {
mat[i][j] = 0;
}
}
}
/**
* check if the index is in the matrix
* @param x position x
* @param y position y
* @return true if the index is in the matrix
* @author Ettori Giammusso
*/
public static boolean isIndexValid(int x, int y) {
return x >= 0 && x < ROWS && y >= 0 && y < COLS;
}
/**
* check if the node was already visited, otherwise visit the node
* @param x position x
* @param y position y
* @param mat matrix of visited nodes
* @return true if the node was visited
* @author Ettori Giammusso
*/
public static boolean isVisited(int x, int y, int[][] mat) {
int temp = mat[x][y];
mat[x][y] = 1;
return temp == 1;
}
}