CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2010
    Posts
    1

    Source code for 3x3 chess board

    Hi ,

    Please send me java code for the below problem,

    Problem : Move the chess piece "KNIGHT" from any location on a

    "3 x 3" Chess Board and make it go to the far right

    hand bottom corner^. Chess Board in the problem is

    not the usual Chess Board of 8 x 8.



    KNIGHT starting position may be any position on board

    Program should exit when knight moves to 3 x 3 corner.



    Here is how my Chess board looks.

    1 2 3

    -------------------------

    | | | |

    1 | | | |

    | | | |

    -------------------------

    | | | |

    2 | | | |

    | | | |

    -------------------------

    | | | |

    3 | | | X | <<<<------- KNIGHT should reach

    | | | | this square.

    -------------------------



    Remember: KNIGHT moves in specific way such as 2 steps in

    one direction and 1 step left/right.

    If the KNIGHT starts are position (2,2) then it cannot move further and

    you have to throw exception with some error message.

    We are not interested in any UI programming.



    Run command: "java <some class> x y", where x is x-coordinate

    and y is y-coordinate(starting position of Knight)

    on the chess board. For this problem x & y could be

    1(min) and 3(max) values and any value(2) in between.





    Deliver : 1) Send me the java code for above problem.

    2) Java code should compile and run.

    3) I will be interested in "Object Oriented Design"

    thought process.

    4) Your coding style

    5) Javadoc

    6) Makefile

    7) Your test results



    I would be more interested in your class design, interface design and error handling, how it will work for a 8 X 8 board, whether the knight picks the shortest path to reach and how you tested this.

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Source code for 3x3 chess board

    You're having a laugh, aren't you?

    Let's see how you would do it first.

    Optimism is an occupational hazard of programming: testing is the treatment...
    K. Beck
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    Feb 2008
    Posts
    966

    Re: Source code for 3x3 chess board

    I just so happen to have this problem already worked out. I am willing to part with it for 8 goats, 5 chickens and 1 elephant. Please let me know if we can work something out (I would be willing to substitute the elephant for a unicorn).

  4. #4
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Source code for 3x3 chess board

    I am willing to part with it for 8 goats, 5 chickens and 1 elephant.
    Ok, where do I send them?
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  5. #5
    Join Date
    Jun 2010
    Posts
    3

    Re: Source code for 3x3 chess board

    Interesting problem...i m also trying but unable to find the shortest path..can any one help?

  6. #6
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Source code for 3x3 chess board

    try this
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  7. #7
    Join Date
    Jun 2010
    Posts
    3

    Re: Source code for 3x3 chess board

    I tried and tried and tried but no luck. Can you share the link you know....

  8. #8
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Source code for 3x3 chess board

    I tried and tried and tried but no luck. Can you share the link you know....
    I don't know of any specific link, I just did a search and read a couple of the articles and they talked of using Dijkstra's algorithm and the A* algorithm. I'm sure with a little more reading/searching I could have found some code or at the every least some pseudo code to implement the algorithms.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  9. #9
    Join Date
    Jun 2010
    Posts
    3

    Re: Source code for 3x3 chess board

    Can you share your code....

  10. #10
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: Source code for 3x3 chess board

    Can you share your code.
    Where did I say I had code?
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  11. #11
    Join Date
    Jun 2007
    Location
    Aurora CO USA
    Posts
    137

    Re: Source code for 3x3 chess board

    Wow, just wow!

    OK, let me take time out from my 40+ hours a week working and my (sometimes non-existent) life to write your homework for you so you don't have to put any effort at all into your final course grade.

    Sorry, just my turn to let off some steam, I guess. Thanks to dlorde, keang and programthis for being more diplomatic.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured