|
I'm trying to set a value into a specific location in the Array. So far I have:
/**
* Sets the specified value in a grid at the location specified by the CoordinatePair parameter.
* This method will be invoked on the display grid.
* @param CoordinatePair object containing the coordinates, and the value to put into that
* location as a char.
*/
public void setSpecificCoordinates(CoordinatePair coordsToSet, char valueToSet)
{
coordsToSet = grid[][]; // I realize this is all wrong
vauleToSet =
}
I'm at a total loss as how to do this. The CoordinatePair is a simple class that has accessor methods for row and column and set methods for row and column. I'm not sure how to use CoordinatePair in the class that I am creating now. (which is a 2-D Array)
Any help would be appreciated.
Thanks.
Maig.
<Added>
I have been working on it and I'm a little closer but I'm getting an error at the if statement line...
public void setRandomCoordinates(int numCoordsToSet, char valueToSet)
{
CoordinatePair coords;
int counter = 0;
while (counter < numCoordsToSet)
{
coords=getRandomCoordinates();
if (coords.equals valueToSet) // test if the coordinates already have a target char - error here
{
getRandomCoordinates(); // get new coordinates
}
else
coords=valueToSet; // set the valueToSet into the coordinates
}
}
|
|
|
should be
coords.equals(valueToSet)
|
|
But you cannot test a CoordPair with a char as equals.
You want to get the char at the CoordPair location and test that against the "valueToSet" or see if it is blank or whatever you're interested in.
|
|
|
Thank you so much!
I was wondering, are there any really good intro to Java tutorials on the web or places to go to learn about it?
I'm using a website called MindLeaders and the previous courses I took were great (HTML, CSS, etc.) but this Java is very hard to understand for me. I have never programmed before.
Thanks!
Maig
|
|
|
|
|
|
|
|
|
// |