2D array

Crooksy's Avatar
Newbie Member

Could someone help me out, I am very new to programming( as one could tell by the Question I am about to ask.)

I am trying to assign a value to random spots in a 2D array. This is what I have so far:

     * Generates random coordinates, puts them into a new CoordinatePair,
     * returns CoordinatePair - This method is complete and requires no change.
     * @return a randomly-generated pair of coordinates within the bounds of the
     * grid
    private CoordinatePair getRandomCoordinates()
        CoordinatePair coords = new CoordinatePair();  // create a new coordinate pair object
        coords.setRow(random.nextInt(ROWS));           // randomly select a row, put row info into object
        coords.setColumn(random.nextInt(COLUMNS));     // randomly select a column, put column info into object
        return coords;                                 // return the object
     * Invokes getRandomCoordinates() to put a specific value into the number of
     * grid positions specified by the first parameter, e.g. 
     * setRandomCoordinates(5, 'T') will set the target char 'T' into 5 different
     * locations in the grid on which it is invoked. This method will be invoked on the 
     * working grid.
     * @param the number of randomly-generated coordinates to set with the value,
     * the target value to set
This is where I need help, setting up this next method:

public void setRandomCoordinates(int numCoordsToSet, char valueToSet)

Last edited by shabbir; 21Sep2006 at 10:55.. Reason: Code block
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Isnt the set method just simple value putting into the class member variable. Can you put the class which has this function as set should just assign the value.