I'm on the verge of making it work, however I keep getting an index out of bounds exception, here is the code thus far:
import java.util.*;
public class cba
{
public static void main(String [] args) {
//For all incrementing purpouses, the int variables i and x are
//used, and set to the required value
int i = 0;
int x = 0;
//Creates an array of 26 index locations to store the 1337 alphabet
//within.
String[] leet = new String[27];
//a
leet[0] = "/-\\";
//b
leet[1] = "|3";
//c
leet[2] = "[";
//d
leet[3] = "|)";
//e
leet[4] = "3";
//f
leet[5] = "|=";
//g
leet[6] = "9";
//h
leet[7] = "|-|";
//i
leet[8] = "1";
//j
leet[9] = ";";
//k
leet[10] = "|<";
//l
leet[11] = "|_";
//m
leet[12] = "|\\/|";
//n
leet[13] = "|\\|";
//o
leet[14] = "0";
//p
leet[15] = "|*";
//q
leet[16] = "*|//";
//r
leet[17] = "|2";
//s
leet[18] = "5";
//t
leet[19] = "7";
//u
leet[20] = "|_|";
//v
leet[21] = "\\/";
//w
leet[22] = "\\/\\/";
//x
leet[23] = ")(";
//y
leet[24] = "'/";
//z
leet[25] = "2";
//<space>
leet[26] = " ";
/* creates an array and stores all the letters of the ASCII value of
each letter in the alphabet within it in each index, it does this by
inititializing variable x with 65, the ASCII value of A in the alphabet
*/
x = 65;
int[] abc = new int[27];
while( i < 26) {
abc[i] = x;
x++;
i++;
}
//26th index position for space's in the abc[] array.
abc[26] = 32;
Scanner keyboard = new Scanner(System.in);
System.out.println("Input the 1337 sentence to translate to english: ");
String sentence = keyboard.nextLine();
int sentenceLength = sentence.length();
//creates a char array of the sentence.
char letters[] = sentence.toCharArray();
//creates another char array to store newly interpreted letters within
String[] translated = new String[10 * sentence.length()];
i = 0;
x = 0;
int y = 0;
int numStrings = 0;
//This loop will find out how many strings there are within the
//setence and store it within numStrings.
while ( y < sentenceLength )
{
if( sentence.charAt(x) == abc[26] )
{
numStrings++;
}
x++;
y++;
}
System.out.println(numStrings);
x = 0;
y = 0;
i = 0;
//this is the new array nextWord[], its length is determined by the
//number of strings there were in the charArray sentence.
String[] nextWord = new String[numStrings];
//this loop uses the variable numStrings as its termination value, the
//purpouse of this loop is to add a new string in each index of the
//array nextWord[].
while ( y < numStrings )
{
if( sentence.charAt(x) == abc[26] )
{
nextWord[i] = sentence.substring(i);
i++;
}
sentenceLength--;
x++;
y++;
}
i = 0;
//prints the words (testing purpouses)...
/*while ( i < numStrings )
{
if ( nextWord[i] == null )
{
break;
}
System.out.print( nextWord[i] );
i++;
} */
i = 0;
x = 0;
//begins interpretation loop
while ( i < numStrings )
{
if ( nextWord[i] == leet[x] )
{
System.out.print( abc[x] );
i++;
x = -1;
}
x++;
}
System.out.println();
}
}
I don't understand why its makking the index out of bounds error though...