Problem z wczytaniem danych do dwuwymiarowej tablicy obiektów.

0

Witam. Mam problem. Wiem że odczyt danych z pliku działa w 100% poprawnie. Nie wiem dlaczego w momencie przypisania do obiektu cell[i][j] to przypisanie nie następuje i w rezultacie mam pustą tablicę cell[9][9]

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sudokugame;

import java.io.IOException;

/**
 *
 * @author micha
 */
public class SudokuGame {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        Grid grid = new Grid();
        grid.readGrid("G:/plik.txt");
        grid.printGrid();
        System.out.println();
        Solver game_solve = new Solver();
        game_solve.solve();
        
        //grid.printGrid();
    }
    
}

public class Grid { 
    static Cell[][] cell = new Cell[9][9];
    public static void readGrid(String nazwa) throws FileNotFoundException
    {
        File file = new File (nazwa);
        int number;
        Scanner sc = new Scanner(file);
        while (sc.hasNext())
        {
            //read sudoku from text file into 9x9 array
            for (int i = 0; i < 9; i ++)
            {
                for (int j = 0; j < 9; j++)
                {
                    cell[i][j] = new Cell();
                    number = sc.nextInt();
                    cell[i][j].value = number;
                    System.out.print(cell[i][j].value);
                }
            }
        }
    }
    
    public static void printGrid()
    {
        for (int i = 0; i < 9; i ++)
        {
            for (int j = 0; j < 9; j++)
            {
                //output the array
                System.out.print(cell[i][j].value);
            }
            //add new line at the end of each row
            System.out.println();
        }
    }
         
}
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sudokugame;

/**
 *
 * @author micha
 */
public class Cell {
    int value;
    boolean isEmpty(){
        if(value==0)
            return true;
        else
            return false;
    };
    int getCellValue(){
        return value;
    }
}

8 0 0 0 0 0 0 0 0
0 0 3 6 0 0 0 0 0
0 7 0 0 9 0 2 0 0
0 5 0 0 0 7 0 0 0
0 0 0 0 4 5 7 0 0
0 0 0 1 0 0 0 3 0
0 0 1 0 0 0 0 6 8
0 0 8 5 0 0 0 1 0
0 9 0 0 0 0 4 0 0

Wczytywany plik.

2

Nie ważne dałem rade.

1 użytkowników online, w tym zalogowanych: 0, gości: 1