File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes need code for the following problem..plz Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "need code for the following problem..plz" Watch "need code for the following problem..plz" New topic

need code for the following problem..plz

Chinmayananda Behera

Joined: Dec 23, 2006
Posts: 1

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.

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"

thaught process.

4) Your coding style

5) Javadoc

6) Makefile

I would be more interested in your class design, interface design and error handling.

please mail the solution to

thanks n regards

Chinmaya<br />Bangalore
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Do your own homework.

This forum is meant for the Sun Certified Java Programmer certification. Moving to Java In General (Beginner)...

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Oh yes, you have forgotten the billing address.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Hey, welcome to the ranch! As you've seen, we don't do work from scratch for you. The ranch works wonderfully well if you post code that almost works. So take a shot at it, show us where you get stuck. One bit of advice is to take small bites. Solve the smallest part of the problem you can think of. Maybe set up the playing board, put your kniggit out there and see if you can plot one move.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
pete stein

Joined: Feb 23, 2007
Posts: 1561
For a humorous but truthful comment on folks posting homework assignments in here without doing any of the work and expecting others to do the work for them, take a peak at what jmcilhinney wrote in a codeguru thread here.
[ March 14, 2007: Message edited by: pete stein ]
I agree. Here's the link:
subject: need code for the following problem..plz
It's not a secret anymore!