Results 1 to 7 of 7
- 04-27-2011, 09:05 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 4
- Rep Power
- 0
Boggle Game and searching for Words
I am sure everyone knows what boggle is. So this is my method
private boolean searchWord(int row, int col, String[] word) {
and if it finds a word it will return, true. so it will need to start of searching at row, col so i guess [0][0]. and needs to search going left, right, up, down, and diagonally in all directions. so basically when i run the program as of now it randomly generates letters on the board, for ex)
h d f z
q o p m
a c b e
u y n i
I do know that i need a few FOR loops. I struggle very much with nested FOR loops. I am guessing it starts of like this
for ( int row = 0; row < row.length; row++) {
for (int col = 0; col < col.length[row]; col ++) {
Please and thank you for help.
- 04-27-2011, 09:49 PM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,546
- Rep Power
- 11
What is searchWord() supposed to do - in particular what do the arguments represent?
Whatever your answer, the place to start is to imagine how you - rather than the computer - would find the answer. You should be able to give a complete and detailed description of the steps you would take (an algorithm, basically).
It is not always easy to come up with a precisely specified "recipe" for things that we take for granted and of which we are rather unconscious. But, nontheless, this is the place to start, not just taking some technique (nested loops or whatever) and throwing it at the problem.
--------------------
It's your first post - so I should have said welcome!
Be aware that it's not the custom here to do people's homework for them. I'm sure you didn't expect that. But at the moment there is little more here than "how do I do this?"
So think about developing an algorithm (strategy) - and post if you are unsure if it will work. Or if you have difficulty translating it into code. Your code and the compiler messages or a description of unwanted runtime behaviour will form the basis of a substantial question.
- 04-27-2011, 11:04 PM #3
Member
- Join Date
- Apr 2011
- Posts
- 4
- Rep Power
- 0
i have already stated what it is supposed to do. "and if it finds a word it will return, true. so it will need to start of searching at row, col so i guess [0][0]. and needs to search going left, right, up, down, and diagonally in all directions."
Basically i need to be able to search the rows, columns. and diagonally for WORDS. the paraments are self explanatory. Also this isnt my WHOLE homework, just one method that I am struggling on. I need to write about 20 methods and this is only one left.Last edited by gdinke; 04-27-2011 at 11:09 PM.
- 04-27-2011, 11:16 PM #4
Member
- Join Date
- Apr 2011
- Posts
- 4
- Rep Power
- 0
and i presume I might have to do some -1, or maybe -2 in the rows, cols at some point? If I could draw you a picture so you know what i mean by this that would help. like i think he said you can search all the way around in the "square." and the next time around ur rows and cols are one less and next time around its 2 less "as in you dont go all the way to the edge" understand what I mean? If it matters I have this instance variable. private Cube[][] place = new Cube[4][4];
Last edited by gdinke; 04-27-2011 at 11:18 PM.
- 04-28-2011, 12:05 AM #5
Senior Member
- Join Date
- Jun 2008
- Posts
- 339
- Rep Power
- 5
Are they? Not to me... the 'word' parameter is an array of Strings - if each String is a word, shouldn't the array variable be called 'words' or 'wordArray' - or is it not an array of words?
And what are the row and column parameters for? You said "it will need to start of searching at row, col so i guess [0][0]". If you are going to start at [0][0], why do you need the parameters?
Just askin'
- 04-28-2011, 12:08 AM #6
Senior Member
- Join Date
- Jun 2008
- Posts
- 339
- Rep Power
- 5
- 04-28-2011, 12:11 AM #7
Member
- Join Date
- Apr 2011
- Posts
- 4
- Rep Power
- 0
in my particular example, searching for the word "dope" starting at 0,1; would return true......searching for word "pod" starting at 1,2; would also return true....rows represents row, and col represents columns. A similar example that I found onthe web is this.. http://www.dreamincode.net/forums/to...y-in-an-array/
Last edited by gdinke; 04-28-2011 at 12:18 AM.
Similar Threads
-
Help: Num to words
By MyOnlineChurva in forum New To JavaReplies: 16Last Post: 01-08-2010, 01:41 AM -
Boggle game - verify words entered by user
By dragonwolf in forum New To JavaReplies: 11Last Post: 11-30-2009, 04:18 AM -
Scrambling Words
By Shadow22202 in forum New To JavaReplies: 9Last Post: 04-30-2008, 03:51 AM -
The words *game* in java programming :confused:
By ibmzz in forum Advanced JavaReplies: 1Last Post: 01-23-2008, 09:23 AM -
help w words
By Gilgamesh in forum New To JavaReplies: 5Last Post: 11-21-2007, 06:15 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks