import java.io.*;
import java.util.*;
public class GameHelper
{
private static final String alphabet = "abcdefg";
private int gridLength = 7;
private int gridSize = 49;
private int[] grid = new int[gridSize]; //array of 49 objects
private int comCount = 0;
public String getUserInput(String prompt)
{
String inputLine = null;
System.out.print(prompt + " ");
try
{
BufferedReader is = new BufferedReader(
new InputStreamReader(System.in));
inputLine = is.readLine();
if(inputLine.length() == 0) return null;
}
catch(IOException e)
{
System.out.println("IOException: " + e);
}
return inputLine.toLowerCase();
}
public ArrayList<String> placeDotCom(int comSize)
{
ArrayList<String> alphaCells = new ArrayList<String>();
String[] alphacoords = new String[comSize];
String temp = null;
int[] coords = new int[comSize];
int attempts = 0;
boolean success = false;
int location = 0;
comCount++;
int incr = 1;
if((comCount % 2) == 1)
{
incr = gridLength;
}
while(!success & attempts++ < 200) //the System.out lines below are for testing purposes only.
{ // they can be commented out when testing is not needed.
location = (int) (Math.random() * gridSize); //get random starting point
System.out.print(" try " + location); //TESTING
int x = 0;
success = true;
while(success && x < comSize) //look for adjacent unused spots
{
if(grid[location] == 0) //if not already used
{
coords[x++] = location; //save location
location += incr; //try 'next' adjacent
if(location >= gridSize) //out of bounds - 'bottom'
{
success = false;
}
if(x > 0 && (location % gridLength == 0)) //out of bounds - right edge
{
success = false;
}
else //found already used location
{
System.out.print(" used " + location); //TESTING
success = false;
}
}
}
x = 0; //turn location into alpha coords
int row = 0;
int column = 0;
System.out.println("\n");
while(x < comSize)
{
grid[coords[x]] = 1; //mark master grid points as 'used'
row = (int) (coords[x] / gridLength); //get row value
column = coords[x] % gridLength; //get numeric column value
temp = String.valueOf(alphabet.charAt (column)); //convert to alpha
alphaCells.add(temp.concat(Integer.toString (row)));
x++;
System.out.print(" coord " +x+ " = " + alphaCells.get(x-1)); //TESTING: statement that tells you exactly
//where the DotCom is located
}
System.out.println("\n");
return alphaCells;
}
}
}
I have forgotten how to place code in a block and I am sorry.
The above code according to the compiler has a missing return statement.
My Command Prompt came up with:
GameHelper.java:101:missing return statement
}
^
Does anyone know what problem is?

