#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Post Array help from input file


    This is my specification:
    You will be writing a Java application which generates a map of a square minefield based on data read from an input file. The first line of input gives the size of the map as an integer (remember it is square!) and each line after that will be a string representing a single row of the grid. A . represents an open space, while an X represents a mine.
    Sample input file:
    Code:
    8
    ......XX
    ........
    .X......
    XX...X.X
    ......X.
    ........
    ....XXX.
    I need to store these data into an array so that I can carry on with the rest of the specification:
    The input only indicates the location of the mines; your program will have to compute the number of adjacent mines for each grid location.
    Your program must be able to perform the following:
     Generate a minefield map by reading data from a given input file.
     Add a mine to any given grid location (row, column) and update the mine counts accordingly.
     Print the minefield, including the mines and mine counts, in the proper formation (see example output in the Testing Phase below).
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    74
    Rep Power
    18
    And your question is?

    This forum is not a homework service. Show us your code, tell us expected output and the perceived output, and the steps you took to solve the problem, and we will he happy to help.

    In case you do want us to fix your homework I would challenge you to hand in our name as the authors.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    Unhappy


    I guess I didn't phrase it well. Before I continued with the final bit of the specification, I noted where I needed to end up with the file read. So basically, how do I get the lines from the text into a usable array to help me get to where I need to go? All I have set up in my code before running out of ideas is setting up all the new File and Scanner statements for the file input, but I'm not sure how to get the nextLine() into the usable array.

    Sorry if you felt as if I was trying to have it done for me, I just worded it weirdly in my frustration.

IMN logo majestic logo threadwatch logo seochat tools logo