-1

public char[][] mapData; Example of it: mapData[k][j] is the character at row k and column j of the map file, which is read with scanner. Here "k" goes from 0 to rows-1, and "j" from 0 to columns-1.

Im stuck with this at the moment, and not sure how to proceed from this?

        BufferedReader br = new BufferedReader(new FileReader(fileName));
        int rows = Integer.parseInt(br.readLine());
        int cols = Integer.parseInt(br.readLine());
        int G = Integer.parseInt(br.readLine());
        int Z = Integer.parseInt(br.readLine());

    char[][] mapData;
    Position[] zombies;
    br.close();

How do i create an array of the rows and how do i implement it into a 2-dimensional array?

Peter
  • 21
  • 1
  • 2
  • 7

1 Answers1

0

If you need just to read a two-dimensional array from the text file you could use one of these solutions: 2d Array from text file c#

Of cause you could add some validation (row and col count).

Community
  • 1
  • 1
Boris Sokolov
  • 1,723
  • 4
  • 23
  • 38