Skip to content
Snippets Groups Projects
Commit 7c8699e5 authored by BEL KHALIFA Mohamed amine's avatar BEL KHALIFA Mohamed amine
Browse files

RandomUtil

parent cb915c5e
No related branches found
No related tags found
No related merge requests found
......@@ -37,7 +37,7 @@ public class ArrayGrid implements Grid{
@Override
public void color(ColorGenerator colorGenerator) {
for(Cell[] column : cells ) {
for(Cell[] column : this.cells ) {
for(Cell cell : column) {
cell.setColor(colorGenerator.nextColor(cell));
}
......
......@@ -15,7 +15,10 @@ public class CellGridIterator implements Iterator<Cell> {
@Override
public boolean hasNext() {
return false;
if(this.row==grid.getNumberOfRows() && this.column==grid.getNumberOfColumns()) {
return false;
}
return true;
}
@Override
......
package util;
import java.util.Random;
import java.util.List;
public class RandomUtil {
private RandomUtil() {}
public static <T> T randomElement(T[] elements, Random random) {
int i = random.nextInt(elements.length);
return elements[i];
}
public static <T> T randomElement(List<T> elements, Random random) {
int i = random.nextInt(elements.size());
return elements.get(i);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment