2D array
Hello,
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:
Code:
/**
* 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)
|