Skip to content
Snippets Groups Projects
Select Git revision
  • 11b6c68b5a2391a05a93f6c1c728cf210072b078
  • master default protected
  • sdas
3 results

TeachingUnitResult.java

Blame
  • Forked from BLAISE KAPLANSKI Teo / 1_HANOUCHE_MOHAMED_2_BLAISEKAPLANSKI_TEO
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    GridIterator.java 780 B
    import java.util.Iterator;
    
     /**
     * {@link GridIterator} instances are used to iterate over the cells of a grid.
     */
    public class GridIterator implements Iterator<Cell> {
        private int rowIndex;
        private int columnIndex;
        private Grid grid;
    
    
        GridIterator(Grid grid) {
            this.rowIndex = 0;
            this.columnIndex = 0;
            this.grid = grid; }
    
    
        @Override
        public boolean hasNext() {
            return columnIndex < grid.getNumberOfColumns() && rowIndex < grid.getNumberOfRows();
        }
    
        @Override
        public Cell next() {
            final Cell result = grid.getCell(rowIndex, columnIndex);
            columnIndex = (columnIndex +1) % grid.getNumberOfColumns();
            if(columnIndex == 0){
                rowIndex++;
            }
            return result;
        }
    }