Skip to content
Snippets Groups Projects
ArrayGrid.java 799 B
Newer Older
  • Learn to ignore specific revisions
  • package model;
    
    public class ArrayGrid implements Grid{
    
    
    BEL KHALIFA Mohamed amine's avatar
    BEL KHALIFA Mohamed amine committed
    
        public void arrayGrid(int numberOfRows, int numberOfColumns) {
            if(numberOfRows <= 0 || numberOfColumns <= 0)
    
                throw new IllegalArgumentException("Le nombre de lignes ou de colonnes ne peut pas être nul ou négatif.");
    
    BEL KHALIFA Mohamed amine's avatar
    BEL KHALIFA Mohamed amine committed
            Cell[][] cells = new Cell[numberOfRows][numberOfColumns];
    
            for(int i = 0; i < numberOfRows; i++) {
    
    BEL KHALIFA Mohamed amine's avatar
    BEL KHALIFA Mohamed amine committed
                for(int j = 0; j < numberOfColumns; j++) {
    
                    cells[i][j] = new SquareCell();
                }
            }
        }
        @Override
        public Cell getCell(int row, int column) {
            return null;
        }
    
        @Override
        public int getNumberOfRows() {
    
    BEL KHALIFA Mohamed amine's avatar
    BEL KHALIFA Mohamed amine committed
            return cells.length;
    
        }
    
        @Override
        public int getNumberOfColumns() {
            return 0;
        }
    }