Skip to content
Snippets Groups Projects
Commit 80ffb187 authored by dragapsy's avatar dragapsy
Browse files

Tache 3 (La methode Next())

parent b38fff22
Branches
No related tags found
No related merge requests found
package model;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class CellGridIterator implements Iterator<Cell> {
ArrayGrid arrayGrid;
......@@ -10,6 +12,8 @@ public class CellGridIterator implements Iterator<Cell> {
public CellGridIterator(ArrayGrid grid) {
arrayGrid=grid;
cells=grid.cells;
rowIndex =0;
columnIndex=0;
}
......@@ -20,6 +24,15 @@ public class CellGridIterator implements Iterator<Cell> {
@Override
public Cell next() {
return null;
if(columnIndex==cells[rowIndex].length)
{
columnIndex=0;
rowIndex++;
}
if(rowIndex== cells.length&& columnIndex==cells[rowIndex].length){
throw new NoSuchElementException();
}
return cells[rowIndex][columnIndex++];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment