Skip to content
Snippets Groups Projects
Commit b85d5d3d authored by TOULLEC Romain's avatar TOULLEC Romain
Browse files

ajout de state et SubMatrixInitializer

parent 78c69d96
No related branches found
No related tags found
No related merge requests found
Pipeline #38390 failed
package matrix;
public class SubMatrixInitializer<T> implements MatrixInitializer<T> {
private final Matrix<T> originalMatrix;
private final Coordinate corner;
public SubMatrixInitializer(Matrix<T> originalMatrix, Coordinate corner) {
this.originalMatrix = originalMatrix;
this.corner = corner;
}
@Override
public T initialValueAt(Coordinate coordinate) {
return originalMatrix.get(coordinate.plus(corner));
}
}
......@@ -44,7 +44,12 @@ public interface State<S> {
* @return The number of times the specified state appears in the list of neighbors.
*/
static <T> int count(T state, List<T> neighbours) {
//TODO: à compléter
return 0;
int count = 0;
for (T neighbour : neighbours) {
if (neighbour.equals(state)) {
count++;
}
}
return count;
}
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment