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
Branches main
No related tags found
Loading
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> { ...@@ -44,7 +44,12 @@ public interface State<S> {
* @return The number of times the specified state appears in the list of neighbors. * @return The number of times the specified state appears in the list of neighbors.
*/ */
static <T> int count(T state, List<T> neighbours) { static <T> int count(T state, List<T> neighbours) {
//TODO: à compléter int count = 0;
return 0; for (T neighbour : neighbours) {
if (neighbour.equals(state)) {
count++;
}
}
return count;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment