Results 1 to 7 of 7
  1. #1
    gdinke is offline Member
    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    Unhappy 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.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    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.

  3. #3
    gdinke is offline Member
    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by pbrockway2 View Post
    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).
    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.

  4. #4
    gdinke is offline Member
    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    Default

    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.

  5. #5
    dlorde is offline Senior Member
    Join Date
    Jun 2008
    Posts
    339
    Rep Power
    6

    Default

    Quote Originally Posted by gdinke View Post
    the paraments are self explanatory.
    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'

  6. #6
    dlorde is offline Senior Member
    Join Date
    Jun 2008
    Posts
    339
    Rep Power
    6

    Default

    Quote Originally Posted by gdinke View Post
    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];
    :confused: sorry, you've completely lost me now.

  7. #7
    gdinke is offline Member
    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    Default

    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

  1. Help: Num to words
    By MyOnlineChurva in forum New To Java
    Replies: 16
    Last Post: 01-08-2010, 01:41 AM
  2. Boggle game - verify words entered by user
    By dragonwolf in forum New To Java
    Replies: 11
    Last Post: 11-30-2009, 04:18 AM
  3. Scrambling Words
    By Shadow22202 in forum New To Java
    Replies: 9
    Last Post: 04-30-2008, 03:51 AM
  4. The words *game* in java programming :confused:
    By ibmzz in forum Advanced Java
    Replies: 1
    Last Post: 01-23-2008, 09:23 AM
  5. help w words
    By Gilgamesh in forum New To Java
    Replies: 5
    Last Post: 11-21-2007, 06:15 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •