|
-
Mar 9th, 2004, 06:01 PM
#1
Thread Starter
Lively Member
queens program
I have to make a program taht alows me to place 8 queens on a chest board with out having them kill on another with there repective movements.
i need to do this program by keeping trake of the movements with a multy bimentional array which i hav no idea how to do. also i have to make a program that runs through all the posible cobination of how the queen can be put on the board and some how show the qween position on an apolet.
but frist i would to know how i ould go about drawing a cheast board on and applet.
i have just started java and would really apercheat the help.
thanx
-
Mar 10th, 2004, 01:33 PM
#2
Thread Starter
Lively Member
how do you make a multy dimentional array and compare the different part of the array to each other
-
Mar 10th, 2004, 01:57 PM
#3
Addicted Member
To make a multi-dimensional array, you do as follows:
Code:
int x = 8;
int y = 8;
private int[][] ArrayName = new int [x][y];
Comparing positions in the array would probably look something like:
Code:
int firstpositionx = 3;
int firstpositiony = 4;
int secondpositionx = 5;
int secondpositiony = 2;
if ( isWithin ( firstpositionx, firstpositiony, secondpositionx, secondpositiony ) ) return true;
else return false;
You could then write a method isWithin ( int a, int b, int c, int d ) which would then take the first two integers a and b, to find a position in the array and then take integers c and d to find a second position. It would then check to see if the first position is within two spaces of the second position.
Code for a basic chess game can be found in a lot of Java books, I'm sure. Make sure you can program the actual game itself before you bother with graphics.
Hope this helps
"'Oh, hello Mr. Crick! What do you think of Jeffrey Archer?' Clip-clip-clip! Oh, come on! Who are you kidding? You wait til I'm mayor, you'll see how tough I am! Christ almighty...."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|