does anyone know of a good tutorial for user info? There is only so much I can figure out from the javadoc and i would really like to learn it.
for (int index = 0; index < xoString.length(); index++)
{
if ('x' == xoString.charAt(index))
{
// process for an 'x' character at index
}
else if ('o' == xoString.charAt(index))
{
// process for an 'o' character at index
}
}String xoString = "xooxxoxxxooxxooxooox";
int levelInt = codeLevelInt(xoString);
String xoStr = decodeLevelInt(levelInt);
System.out.println("The output matches the input: " + xoString.equals(xoStr));
// the above is background
private int codeLevelInt(String xoStr)
{
int levInt = 0;
for (int lev = 0; lev < xoStr.length(); lev++)
{
levInt = levInt * 2;
levInt = levInt + ('x' == xoStr.charAt(xoStr.length() - 1 - lev) ? 1 : 0);
}
return levInt;
}
private String decodeLevelInt(int levInt)
{
String xoStr = "";
while (xoStr.length() < 20)
{
xoStr = xoStr + (levInt % 2 == 1 ? "x" : "o");
levInt = levInt / 2;
}
return xoStr;
}