# Bishops moves

• 01-28-2010, 08:07 PM
michail
Bishops moves
can someone tell me what this means?
the drow-1, dcol-1, why -1

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);                         }```
• 01-28-2010, 08:24 PM
Boxxybabee
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.
• 01-28-2010, 08:31 PM
michail
sorry, let me rephrase that.
i meant what the -1 in here means:
Code:

`return goDiagonal(srow, scol, drow-1, dcol-1,true)`
• 01-28-2010, 09:04 PM
sathishsengg
Is goDiagonal is the Recursive method...?

can u post the code of goDiagonal().
• 01-28-2010, 09:15 PM
michail
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?
• 01-28-2010, 10:33 PM
sathishsengg
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...