Keil Logo Arm Logo

Discussion Forum

Java help please!!!

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Daniel Trieu
Posted
21-Jan-2005 03:54 GMT
Toolset
C166
New! Java help please!!!
Could anyone check my coding here. I'm trying to create a word search program.
I have a 6x6 word board and a file that contain 3 word in the list
6x6 word baord:
A E N T E R
A P A E A A
E N P E R S
A D A L A F
A F A F E F

wordlist:
ACE
APPLE
ENTER

and i'm suppose to search for the word in 8 directions

public void readWord () {
word1 = new char [3][];
puzzle1 = new char [6][6];
finalWord = new char [6][6];
int i,j;
String s,p;
for (i=0; i<word1.length; i++){ //For loop to read in search words
s = puzzle.readString();
word1[i] = s.toCharArray();
}

for (i=0; i<6; i++){ //For loop to read in jumbled puzzle
p = puzzle.readString();
puzzle1[i] = p.toCharArray();
}

//Search
private boolean found1(int i, int b) {
for ( int k=0; k<word1[2].length; k++) {
if(Character.toUpperCase(word1[2][k]) != puzzle1[i][b+k]) {
return false;
}
}
return true;
}


//Forward search method
private void forward(){
boolean tmp = false;
for (int i=0; i<puzzle1.length; i++) {
for (int b=0; b<=word1[13].length; b++){
tmp = found1(i, b);
if (tmp) {
for (int k=0; k<5; k++) {
msg.writeChar(puzzle1[i][b+k]); //foward search

}
}
}
}
Read-Only
Author
Andrew Neil
Posted
21-Jan-2005 07:51 GMT
Toolset
C166
New! RE: Java help please!!!
That code's illegible!

Please read the instructions about posting code, and then do what it says!
(instructions are immediately above the 'Message' box when you make a post!)
Read-Only
Author
Daniel Trieu
Posted
21-Jan-2005 13:10 GMT
Toolset
C166
New! RE: Java help please!!!
the code only works when i put [13], if i put like a variable it doesn't work at all.


thanks!!!
Read-Only
Author
Hans-Bernhard Broeker
Posted
21-Jan-2005 17:15 GMT
Toolset
C166
New! RE: Java help please!!!
And what in god's wide world, if I may be so bold to ask, made you think that this forum was the right place to ask a question about, of all things, Java programming?

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Keil logo

Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.