All pastes #486283 Raw Edit

Rusty

public text v1 · immutable
·published 2007-05-13 20:53 UTC
rendered paste body
==============================================================================================================
C:\code>javac GameHelper.java
GameHelper.java:72: illegal start of type
        while (x < comSize) {
        ^
GameHelper.java:72: > expected
        while (x < comSize) {
                          ^
GameHelper.java:83: illegal start of type
        return alphaCells;
        ^
GameHelper.java:83: <identifier> expected
        return alphaCells;
                         ^
GameHelper.java:85: class, interface, or enum expected
}
^
5 errors


===============================================================================================================




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];
	private int comCount;

	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 sucess = false;
	int location = 0;
	
	comCount++;
	int incr =1;
	if ((comCount % 2) == 1) {
	incr = gridLength;
	}

	while ( !sucess & attempts++ < 200) {
		location = (int) (Math.random() * gridSize);
		System.out.print( " try " + location); // coment this line after testing
		int x=0;
			success = true;
			while( success && x < comSize) {
			  if (grid[location] == 0) {
			    coords[x++] = location;
			    location += incr;
			    if (location >= gridSize){
			       sucess= false;
			    }
			    if(x>0 && (location % gridLength == 0)) {
			    success = false;
			    }
			    }else 
			    //System.out.print("used " + location);
			    success = false;
			    }
			  }
		}



	int x = 0;
	int row = 0;
	int column = 0;
	//System.out.println ("\n");
	while (x < comSize) {
	grid[coords[x]] =1;
	row = (int) (coords[x] / gridLength);
	column = coords[x] % gridLength;
	temp = String.valueOf(alphabet.charAt(column));
	
	alphaCells.add(temp.concat(Integer.toString(row)));
	x++;
	//System.out.print( "  coord " +x+ " = " + alphaCells.get(x-1));
	}
	//System.out.println("\n");
	return alphaCells;
	}
}