Skip to content
Snippets Groups Projects
Commit cb915c5e authored by EL GAOUAL Zaid's avatar EL GAOUAL Zaid
Browse files

CellGridIterator nextcell

parent 3162b523
Branches
No related tags found
No related merge requests found
......@@ -4,9 +4,13 @@ import java.util.Iterator;
public class CellGridIterator implements Iterator<Cell> {
public ArrayGrid grid;
public int row;
public int column;
public CellGridIterator(ArrayGrid grid) {
this.grid=grid;
this.row=0;
this.column=0;
}
@Override
......@@ -16,12 +20,14 @@ public class CellGridIterator implements Iterator<Cell> {
@Override
public Cell next() {
for(int i = 0; i < grid.getNumberOfRows() ; i++) {
for(int j = 0; j < grid.getNumberOfColumns(); j++) {
}
if (row>=0 && row< grid.getNumberOfRows()-1){
this.row=row+1;
}
else if(row== grid.getNumberOfRows()-1 && column< grid.getNumberOfColumns()-1){
this.row=0;
this.column+=1;
}
return Cell;
return grid.getCell(column,row);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment