Results 1 to 5 of 5
  1. #1
    Hardo is offline Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Default Help - maxLength method for 2D Array

    Hey guys I have been working on this game for over a week now and have managed to get everything working except the maxLength(int row, int col); method. this is a Gomoku game and what the method has to do is:

    SOLVED
    Last edited by Hardo; 09-15-2009 at 02:13 AM.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You didn't explain what the problem with the method is.
    Do you get a compilation error, run time exception, wrong results?

  3. #3
    Hardo is offline Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Default

    it compiles and runs but when i put in say the position 12, 9 it sees that there is nothing there so it returns a line length of 0, that works. but if there is say a B (black) toke at 12, 9 the method maxLength is supposed to look in each vertical, horizontal and both diagonals to find out of those directions what is the length of the longest line of B (black) tokens. instead atm it only returns a value of 1 if there is a value at the co-ords eventhough there is a B(black) token next to it making it a line of 2 tokens so it should return 2. but its not.

  4. #4
    Hardo is offline Member
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Default

    Now i have that working but what isnt working is the line check that does the diagonal that goes south west and north east of co-ords. Now i think i have to set rinc and cinc to 0 and the opposite is -0 . this isnt working its not returning the correct value. what value can i set rinc and cinc to check in those directions?? or is there another way?

    -Thanks in advance

    SOLVED
    Last edited by Hardo; 09-15-2009 at 02:13 AM.

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You are going to have to think out and write down your algorithm and then verify it before you even get close to the compiler.

Similar Threads

  1. Learning - 2D array and method question.
    By Russo in forum New To Java
    Replies: 24
    Last Post: 09-15-2009, 09:16 AM
  2. Recursive method using int array, help needed
    By chupalo17 in forum New To Java
    Replies: 4
    Last Post: 09-08-2009, 12:15 AM
  3. Array Method Testing
    By Suzanne1187 in forum Java Applets
    Replies: 1
    Last Post: 04-15-2009, 09:23 AM
  4. Replies: 2
    Last Post: 02-24-2009, 05:32 PM
  5. Int Array Allowed in main() Method?
    By Starclopsofish in forum New To Java
    Replies: 19
    Last Post: 10-03-2008, 05:22 PM

Posting Permissions

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