1. Member
Join Date
Dec 2009
Posts
31
Rep Power
0

## Bishops moves

can someone tell me what this means?
the drow-1, dcol-1, why -1

Java Code:
``` boolean goDiagonal(int srow, int scol, int drow, int dcol, boolean theEnd)
{
if ((drow - srow) == (dcol - scol))//right and down
{
if (dcol - scol >0) //right down
{ //move rightdown
return goDiagonal(srow, scol, drow-1, dcol-1,true); //if it meets one piece then stop
}
else
{//move rightup
return goDiagonal(srow, scol, drow +1, dcol +1,true);
}```
Last edited by michail; 01-28-2010 at 09:14 PM.

2. I think its saying that if the int drow minus the int srow equals int dcol minus the int scol, then the the block of code inside the if statment.

3. Member
Join Date
Dec 2009
Posts
31
Rep Power
0
sorry, let me rephrase that.
i meant what the -1 in here means:
Java Code:
`return goDiagonal(srow, scol, drow-1, dcol-1,true)`

4. Member
Join Date
Jan 2010
Posts
10
Rep Power
0
Is goDiagonal is the Recursive method...?

can u post the code of goDiagonal().

5. Member
Join Date
Dec 2009
Posts
31
Rep Power
0
I updated the code. That was the goDiagonal. What do you mean recursive? It.s for the bishop does that have anything to do with it?

6. Member
Join Date
Jan 2010
Posts
10
Rep Power
0
The method calls itself is recursive method..

Now you edited the code as recursive method,
In your code, "goDiagonal" method calls "goDiagonal" itself is recursive....

hard to explain the recursive method here, better refer it,

what the code does is....
code checking from scol to dcol and srow to drow, whether it meets any other piece or not.
example : scol =1 srow=1 dcol=4 drow=4 (Source is (1,1) and Destination (4,4))

then it Checks whether it meets any other piece from (2,2),(3,3) and finally (4,4) positions, "goDiagonal(srow, scol, drow-1, dcol-1,true)" recursive method doing this only...

#### Posting Permissions

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