i have this method , which returns true no matter what numbers i feed into it:

public boolean piecesCollision(ChessPiece[][]pieces,int rowStart,int columnStart ,int columnEnd,int rowEnd) {
		
		int j=columnStart;
		int i=rowStart;
		boolean valid5=false;
		boolean valid6=false;
		boolean valid7=false;
		boolean valid8=false;
          
		
		int b=0;
		int SpacesX=rowEnd-rowStart;
		
		int SpacesY=columnEnd-columnStart;
		   
		        
		if(SpacesY>0 & SpacesX==0){ // RIGHT SIDE (CHECK FOR NULL)
				  	  
			 
					
			            
						    while(pieces[rowStart][columnStart+b]==null && columnStart<columnEnd){
						     b++;
						     columnStart++; 
				 
		             }
				
			  
		    if(b<SpacesY){
			valid5=false;
            }
            else{
			valid5=true;
            }	 // IF B SMALLER THAN THE DIFFERENCE BETWEEN COLUMNSTART & COLUMNEND (SPACESY) , GIVE FALSE. OTHERWISE GIVE TRUE.
		
		
		}
		
		if(SpacesY<0 & SpacesX==0){ // LEFT SIDE (CHECK FOR NULL)
						  	  
				
							  
						    while(pieces[rowStart][columnStart-b]==null && columnStart>columnEnd){
						     b++;
						     columnStart--; 
				  
							
			}
         			
		
		  if(b<SpacesY){
			valid6=false;
            }
            else{
			valid6=true;
            }			  
					  
		}			  
		   if(SpacesY==0 & SpacesX>0){ // DOWN SIDE (CHECK FOR NULL)
								  	  
							 
								
						         while(pieces[i+b][columnStart]==null && rowStart<rowEnd){ // CHECKS THE down ROW.
								   b++;
										 
								   rowStart++;
								 
								 
						   
								
					}	
				
		    if(b<SpacesX){
			valid7=false;
            }
            else{
			valid7=true;
            }			
							  
		}					  
							  
							  
				if(SpacesY==0 & SpacesX<0){ // UP SIDE (CHECK FOR NULL)			  
									  	  
							
											
						           while(pieces[rowStart-b][columnStart]==null && rowStart>rowEnd){ // CHECKS THE UPPER ROW.
								   b++;	 
								   rowStart--;
								    }			
							  
                							
				
		    if(b<SpacesX){
			valid8=false;
            }
            else{
			valid8=true;
            }	
		}		
		return valid5 || valid6 || valid7 || valid8;
	}		
}

it returns allways true. how come?
the arguments are different.. each type, i decide on what they will be . the objects are fixed. the objects include chess pieces 16*2

that returns true.

i debugged it , by writing a similar code with print statements and it works. while the other doesnt!!

public class ChessInterface1{
 public static void main(String[] args){	
	int b=0;
	int columnStart=5;
	int columnEnd=2;
	int SpacesX=columnStart-columnEnd;
	int array[]=new int[5];
	array[0]=1;
	array[1]=0;
	array[2]=3;
	array[3]=4;
	array[4]=5;
	boolean valid7=false;
if(columnStart>columnEnd){	
	while(array[4-b]!=0 && columnStart>columnEnd){
		        // CHECKS THE UPPER ROW.
			   b++;
					 
			   columnStart--;
			    
	     System.out.println(array[4-b]);
	     System.out.println(b);
	}
}	
	if(b<SpacesX){
		valid7=false;
		System.out.println("The value is false");
	    }
	    else{
		valid7=true;
		System.out.println("The value is true");
	    }	
	   System.out.println("The gap between positions is :"+SpacesX);
	   System.out.println("The array spaces counted in the loop are :"+b);
	   
	}
}

what happens. is my ifs condition get penetrated. i cant conceptually understand. why the while loop doesnt stop when there is a non null object.
could you look simple at the structure of the code. cause i think i have a few variables that are too exposed or too hidden. but which ones/

A suggestion. Change this:

System.out.println(array[4-b]);
	     System.out.println(b);

to this to put a label on the output vs just having a raw number standing there by itself

System.out.println("array[4-b]=" + array[4-b]);
	     System.out.println("b=" + b);

Where do you show the value of SpacesX?

int SpacesX=columnStart-columnEnd;

it is in the code.

any idea on why the code wont work?
why does it return true every single time?!?!?!

Where do you show the value of SpacesX?

I'm never sure when posting on threads about how good the OPs English is.
I asked where in your code you showed the value of a variable. That is where do you print it out so it can be seen in the debug print outs. Your reply says you didn't understand my question because you completely ignored it. The answer to the question would be: I don't show the value of SpacesX because ......

why does it return true every single time

That's good that it returns true every time. That means the computer is operating correctly. If it were true sometimes and false others, that would be bad.

Norm. you are like schizophrenic. you jump between topics like mad.

why are you concerned with spaceX

to make you happy . here:
#
int columnStart=5;
#
int columnEnd=2;
#
int SpacesX=columnStart-columnEnd;

3=2-5

if(b<SpacesX){
gives true or not true answer

System.out.println("The gap between positions is :"+SpacesX);

thats all you need to know. that was the debugging code. really simple. works lovily


now back to my original code. i have a few suspicious.

int b=0;
		int SpacesX=rowEnd-rowStart;
		
		int SpacesY=columnEnd-columnStart;
		   
		        
		if(SpacesY>0 & SpacesX==0){ // RIGHT SIDE (CHECK FOR NULL)
				  	  
			 
					
			            
    while(pieces[rowStart][columnStart+b]==null && columnStart<columnEnd){
						     b++;
						     columnStart++; 
				 
		             }
				
			  
		    if(b<SpacesY){// should i include all the if condition inside or outside the initial if statement. i want it to be visible and get to the return stage.
			valid5=false;
            }
            else{
			valid5=true;// why is program obsessed with giving out this value?
            }
		
		
		}

The point was the debug output in your code was incomplete because it did NOT show the values of ALL the variables used.

now back to my original code

You've removed all the debug code. Does that mean that there is no problem with the code now.

In case you were wondering, I am not going to do any debugging of your code. It's completely up to you to find the problems.


Good luck.

i did all the debugging.

i need someone to look at the syntax. cause it is causing the problem. if i could do it by myself i would, i dont thing i conceptually understand the order of things i put the whole thing altogether

The point was the debug output in your code was incomplete because it did NOT show the values of ALL the variables used.

it showed enough variables.
it showed the distance between pieces
variable b
columnStart-- (if i remember right)
if hte result
and the output in general

that code works. why dont you try it. feed different numbers in the columnStart and End..and you will get true , false accordingly

Norm1, if you dont the solution to the problem, it is okay to say, "i dont know"!

Absolutely I DONT KNOW. I'm not going to spend time trying to figure out the logic in your program. That is your problem.

Hi NewOrder. You seem very close to losing the last person who is really trying to help - being rude to Norm is very short-sighted.
Consider a few points from your last post:

i need someone to look at the syntax. cause it is causing the problem.

No it isn't. If your syntax is invalid the compiler will tell you. If you have no compiler errors then its not a syntax error, its a program logic error.

it showed enough variables.

No it didn't. IF it had showed enough variables then you would know where your error was.

i did all the debugging.

Don't be so stupid. If you had done all the debugging you would haver no bugs left. You obviously have not done all the debugging.

i dont thing i conceptually understand the order of things i put the whole thing altogether

If that's true then you have no chance of getting this right - even if you get this particular bit of code to produce the result you want, it may still be unhelpful or irrelevant.
(For example: Your method "piecesCollision" returns a boolean (it's not commented, but presumably it shows whether there was a collision). So what next? Don't you want to know which piece it collided with (one of yours, one from the other side, the other side's king?). How does your method help with that? If you don't know exactly what you need from this part of the program, then how can you design, code or verify it?)

here is a full debugging of the rook position (moving left or right) it is similar with moving up or down.

2 methods. main and a boolean method.

here is the code

public class ChessInterface1{
 public static void main(String[] args){	
	   int columnStart=4;
	  int columnEnd=2;
		
		int array[]=new int[5];
		array[0]=1;
		array[1]=2;
		array[2]=0;
		array[3]=4;
		array[4]=5;
		
	 isThisTrue(array,columnStart,columnEnd);

	

 }
 
 public static boolean isThisTrue(int[]array,int columnStart,int columnEnd){
		int b=0;
		int SpacesX=columnStart-columnEnd;
		boolean isRookMovingLeft=false;
		boolean isRookMovingRight=false;
	

		
		
		
	 if(columnStart>columnEnd){	
		 
			
		 while(array[columnStart-b]!=0 && array[columnStart-b]!=array[columnEnd]&& array[columnEnd]!=0 ){ 
		 b++;	 
			
	     }			
	    System.out.println("LEFT(ColumnStart>ColumnEnd) the value of b is "+b );
		if(SpacesX<0){
		SpacesX=SpacesX*(-1); 
		}	
		
		System.out.println("LEFT(ColumnStart>ColumnEnd) the distance is "+ SpacesX);
		if(b<SpacesX){
			isRookMovingLeft=false;
		System.out.println("LEFT (ColumnStart>ColumnEnd) The value is false");
		}
		else{
			isRookMovingLeft=true;
		System.out.println("LEFT (ColumnStart>ColumnEnd)  The value is true");
		}	
	}
 
	 
	 if(columnStart<columnEnd){	
		 
			
		    while(array[columnStart+b]!=0 && array[columnStart+b]!=array[columnEnd] && array[columnEnd]!=0){ 
			   b++;	 
			System.out.println(array[columnStart+b]);
			    }			
		System.out.println("RIGHT(ColumnStart<ColumnEnd) the value of b is "+b );
		
		
		if(SpacesX<0){
			SpacesX=SpacesX*(-1); 
			}
		
		System.out.println("RIGHT(ColumnStart<ColumnEnd) the distance is "+ SpacesX);
		if(b<SpacesX){
			isRookMovingRight=false;
		System.out.println("RIGHT(ColumnStart<ColumnEnd) The value is false");
		}
		else{
			isRookMovingRight=true;
		System.out.println("RIGHT(ColumnStart<ColumnEnd) The value is true");
		}	
	}
	 
	 
 return isRookMovingRight || isRookMovingLeft;
 }
 
 }

OK, so that's some code with lots of prints in it (good).
But I have absolutely no idea what that code is supposed to achieve, so how can I tell if it's right or wrong?

James, i explained before.
you need to reach from starting to end position without encountering object (in the example , debugging , encounter 0. you can put 0 and change the columnstart, columnend variabes ) and check the codes credibility.
try it.
if you understand that debugged code , you will understand the analogue of this code to my chess code

I know the rules of chess. I find it hard to relate your code to them. You have given up on comments again already. All that stuff about changing variables is not a description of what the code is supposed to achieve.
Look, here's an example from a chess program, it's part of the code for the Piece class:

Collection<Square> getValidMoves() {
    // returns a collection of all the Squares that this piece
    // can legally move to at this time.
    ...
}

Can you feel the difference?

i am doing java for 3 months .. this project is a bit hard for me. 2 months ago i could do a code of 20 lines. and this code stretches to over 1000 lines.

i am going to post here a code. only one static boolean method (chessCollision) and a main (that will contain array of strings only

. i havent learned collection methods. but i did hear about them..

public class ChessInterface1{
 public static void main(String[] args){	

	   int rowStart = 8;
	   int rowEnd=6;
	   int columnStart = 8;
	   int columnEnd=8;	
	 
	 
	 String[][]pieces =new String[9][9];
	 
	   pieces[2][1]="Twenty One";
	   pieces[2][2]="Twenty Two";
	   pieces[2][3]="Twenty Three";
	   pieces[2][4]="Twenty Four";
	   pieces[2][5]="Twenty Five";
	   pieces[2][6]="Twenty Six";
	   pieces[2][7]="Twenty Seven";
	   pieces[2][8]="Twenty Eight";
	   					  
	      pieces [1][1]="Twenty Eight";
		  pieces [1][2]="Twenty Eight";
		  pieces [1][3]="Twenty Eight";
		  pieces [1][4]="Twenty Eight";
		  pieces [1][5]="Twenty Eight";
		  pieces [1][6]="Twenty Eight";
		  pieces [1][7]="Twenty Eight";
		  pieces [1][8]="Twenty Eight";		  
  
		   pieces[7][1]="Twenty Eight";
		   pieces[7][2]="Twenty Eight";
		   pieces[7][3]="Twenty Eight";
		   pieces[7][4]="Twenty Eight";
		   pieces[7][5]="Twenty Eight";
		   pieces[7][6]="Twenty Eight";
		   pieces[7][7]="Twenty Eight";
		   pieces[7][8]="Twenty Eight";
		   	   	  
		      pieces [8][1]="Twenty Eight";
		     pieces [8][2]="Twenty Eight";
			  pieces [8][3]="Twenty Eight";
			  pieces [8][4]="Twenty Eight";
			  pieces [8][5]="Twenty Eight";
			  pieces [8][6]="Twenty Eight";
			  pieces [8][7]="Twenty Eight";
			  pieces [8][8]="Twenty Eight";
			  
			  
			 if(piecesCollision(pieces, rowStart,columnStart , columnEnd, rowEnd)){
				 System.out.println("This statement is true");
			 }
			 else{
				 System.out.println("This statement is false");
			 }
	 
 }

 
 
 public static boolean piecesCollision(String[][]pieces,int rowStart,int columnStart ,int columnEnd,int rowEnd) {
		
		
		boolean isRookMovingRight=false;
		boolean isRookMovingLeft=false;
		boolean isRookMovingDown=false;
		boolean isRookMovingUp=false;
       
		
		int b=0;
		int rowX=rowEnd-rowStart;
		
		int columnY=columnEnd-columnStart;
		   
		        
		if(columnY>0 & rowX==0){ // RIGHT SIDE (CHECK FOR NULL)
				  	  
			 
					
			            
		  while(pieces[rowStart][columnStart+b]==null && pieces[rowStart][columnStart+b]!=pieces[rowStart][columnEnd] && pieces[rowEnd][columnEnd]==null){
						     b++;
						   
				 
		             }
				
			  
		    if(b<columnY){
			isRookMovingRight=false;
         }
         else{
			isRookMovingRight=true;
         }	 // IF B SMALLER THAN THE DIFFERENCE BETWEEN COLUMNSTART & COLUMNEND (SPACESY) , GIVE FALSE. OTHERWISE GIVE TRUE.
		
		
		}
		
		if(columnY<0 & rowX==0){ // LEFT SIDE (CHECK FOR NULL)
						  	  
				
							  
		while(pieces[rowStart][columnStart-b]==null && pieces[rowStart][columnStart-b]!=pieces[rowStart][columnEnd] && pieces[rowEnd][columnEnd]==null){
						     b++;
						    
				  
							
			}
      			
		   if(columnY<0){
		   columnY=columnY*(-1);
		   }
		   if(b<columnY){
			isRookMovingLeft=false;
         }
         else{
			isRookMovingLeft=true;
         }			  
					  
		}		

		
		   if(columnY==0 & rowX>0){ // DOWN SIDE (CHECK FOR NULL)
								  	  
							 
								
		   while(pieces[rowStart+b][columnStart]==null && pieces[rowStart+b][columnStart]!=pieces[rowEnd][columnStart] && pieces[rowEnd][columnEnd]==null){ // CHECKS THE down ROW.
								   b++;						   
					}	
				
		    if(b<rowX){
			isRookMovingDown=false;
         }
         else{
			isRookMovingDown=true;
         }			
							  
		}					  
							  
							  
		  if(columnY==0 & rowX<0){ // UP SIDE (CHECK FOR NULL)			  
									  	  										
	     while(pieces[rowStart-b][columnStart]==null && pieces[rowStart-b][columnStart]!=pieces[rowEnd][columnEnd] && pieces[rowEnd][columnEnd]==null){ // CHECKS THE UPPER ROW.
								   b++;	 
								  
								    }			
							  
          if(rowX<0){
		     rowX=rowX*(-1);   							
			}	
		    if(b<rowX){
			isRookMovingUp=false;
         }
         else{
			isRookMovingUp=true;
         }	
		}		
		return isRookMovingRight || isRookMovingLeft || isRookMovingDown || isRookMovingUp;
	}		
}

here is the whole thing. all the code and its purpose!!
this time i am trying do the same that i did with my original code, but this time with string. you could feed different numbers at the column row variables at the very top. i cant see where is the problem though

I understand that you are a beginner, and that what you attempting is hard. We are trying to help, please think about what we say.
You still need to document what this code is supposed to achieve. Without that there's no way anyone can tell whether it works correctly, or, if not, why not. I, personally, still have no idea what this code is intended to return or why.

i have been testing it for some time.
here is where the problem is
int b=0;

while(pieces[rowStart-b][columnStart]==null && rowStart-b!=rowEnd && pieces[rowEnd][columnEnd]==null){ // CHECKS THE UPPER ROW.
								   b++;	 
								  
								    }

pieces[rowStart-b][columnStart]==null inside the while loop. i dont think it is correct. what i think it does, it puts 0 first. which isnt true, cause the first piece is the piece (object i am trying to move).

then i tried something like that:

while(pieces[rowStart-1-b][columnStart]==null

it gave me false. does it repetitively remove -1 or does it do it once?!?


i think i traced the problem. it must be there


my goal is to count the number of nulls from one point of the array to another. the while statement needs to count all the null.. from one space of the array to another.

example
pieces[1][2] to pieces[1][8]

if null was found , b should be incremented. if an object is met, the loop should stop.

thats everything i need to do to be able to operate 20% of the code.


i tried this now. it works. but my whole code hates it , it gives arrayoutofbound mistake:( dont know why

while(pieces[rowStart-1-b][columnStart]==null & rowStart-b!=rowEnd && pieces[rowEnd][columnEnd]==null){ // CHECKS THE UPPER ROW.
								   b++;	 
								  
								    }

i dont think it is correct...cause the first piece is the piece
my goal is to count the number of nulls from one point of the array to another. the while statement needs to count all the null.. from one space of the array to another...
if an object is met, the loop should stop.

How do i reconcile all these? Do you mean "count the consecutive nulls ignoring the cell at the start coordinates" Is "an object is met" the same as "array element is not null"?

ps: when you "meet an object" do you care whether its a piece of the same side or the other side? - because you can't move into a square occupied by one of your own pieces, but you can move into a square occupied by an opponent's piece.

James i took care of the white vs black pieces. when it meets an object it must stop.
here is the debugged version. it works with strings but not with objects. why?


The only one who i can ask is someone who understands java well.
when i have a main and one method with array of strings , all the array works perfectly.

but when the method filled with an array of objects it doesnt work.
i have a few classes for each piece. the array has references to all. may be the array is burried so much inside the method in another classes piece that it prevents extraction/?

String array. code.

public class ChessInterface1{
 public static void main(String[] args){	

	   int rowStart = 8;
	   int rowEnd=1;
	   int columnStart = 8;
	   int columnEnd=8;	
	 
	 
	 String[][]pieces =new String[9][9];
	 
	   pieces[2][1]="Twenty One";
	   pieces[2][2]="Twenty Two";
	   pieces[2][3]="Twenty Three";
	   pieces[2][4]="Twenty Four";
	   pieces[2][5]="Twenty Five";
	   pieces[2][6]="Twenty Six";
	   pieces[2][7]="Twenty Seven";
	   pieces[2][8]=null;
	   					  
	      pieces [1][1]="Twenty Eight";
		  pieces [1][2]="Twenty Eight";
		  pieces [1][3]="Twenty Eight";
		  pieces [1][4]="Twenty Eight";
		  pieces [1][5]="Twenty Eight";
		  pieces [1][6]="Twenty Eight";
		  pieces [1][7]="Twenty Eight";
		  pieces [1][8]=null;		  
  
		   pieces[7][1]=null;
		   pieces[7][2]="Twenty Eight";
		   pieces[7][3]="Twenty Eight";
		   pieces[7][4]="Twenty Eight";
		   pieces[7][5]="Twenty Eight";
		   pieces[7][6]="Twenty Eight";
		   pieces[7][7]="Twenty Eight";
		   pieces[7][8]=null;
		   	   	  
		      pieces [8][1]=null;
		     pieces [8][2]="Twenty Eight";
			  pieces [8][3]="Twenty Eight";
			  pieces [8][4]="Twenty Eight";
			  pieces [8][5]="Twenty Eight";
			  pieces [8][6]="Twenty Eight";
			  pieces [8][7]=null;
			  pieces [8][8]=null;
			  
			  
			
	 
 

 
 

		
		
		boolean isRookMovingRight=false;
		boolean isRookMovingLeft=false;
		boolean isRookMovingDown=false;
		boolean isRookMovingUp=false;
       
		
		int b=0;
		int rowX=rowEnd-rowStart;
		
		int columnY=columnEnd-columnStart;
		   
		    System.out.println("rowX "+rowX);
		    System.out.println("columnY "+columnY);
		
		////////////////////////////////////////////////////////////////////////////////////////////////////////////
		if(columnY>0 & rowX==0){ // RIGHT SIDE (CHECK FOR NULL)
				  	  
			 
					
		  b=1;	
		  while(pieces[rowStart][columnStart+b]==null && columnStart+b!=columnEnd && pieces[rowEnd][columnEnd]==null){
						     b++;
						   
				 
		             }
		
		  System.out.println("B "+ b );
			
			   
			  
		    if(b<columnY || columnY==0 || b==0 ){
			isRookMovingRight=false;
			System.out.println("This is false "+ b+ " This is space "+ columnY);
         }
         else{
			isRookMovingRight=true;
			System.out.println("This is true "+ b+ " This is space "+ columnY);
         }	 // IF B SMALLER THAN THE DIFFERENCE BETWEEN COLUMNSTART & COLUMNEND (SPACESY) , GIVE FALSE. OTHERWISE GIVE TRUE.
		
		
		}

		
		//////////////////////////////////////////////////////////////////////////////////////////////////////
		
		
		
		
		if(columnY<0 & rowX==0){ // LEFT SIDE (CHECK FOR NULL)
						  	  
				
							  
		while(pieces[rowStart][columnStart-1-b]==null && columnStart-b!=columnEnd && pieces[rowEnd][columnEnd]==null){
						     b++;
						    
				  
							
			}
      			
		  
	
		columnY=columnY*(-1); 
		if(b<columnY || columnY==0 || b==0 ){
				isRookMovingLeft=false;
				System.out.println("This is false "+ b+ " This is space "+ columnY);
		     }
		     else{
				isRookMovingLeft=true;
				System.out.println("This is true "+ b+ " This is space "+ columnY);
		     }			  
						  
		}		
					  
			

		
		
		
		//////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		   if(columnY==0 & rowX>0){ // DOWN SIDE (CHECK FOR NULL)
			  	  
				 
				b=1;
			   while(pieces[rowStart+b][columnStart]==null && rowStart+b!=rowEnd && pieces[rowEnd][columnEnd]==null){ // CHECKS THE down ROW.
									   b++;						   
						}	
			  
			   
			    if(b<rowX || rowX==0 || b==0 ){
				isRookMovingDown=false;
				System.out.println("This is false "+ b+ " This is space "+ columnY);
	         }
	         else{
				isRookMovingDown=true;
				System.out.println("This is true "+ b+ " This is space "+ rowX);
	         }			
								  
			}	  
							  
		/////////////////////////////////////////////////////////////////////////////////////						  
		  if(columnY==0 & rowX<0){ // UP SIDE (CHECK FOR NULL)			  
			 // (array[columnStart-b]!=0 && array[columnStart-b]!=array[columnEnd]&& array[columnEnd]!=0 )	
		
	     while(pieces[rowStart-1-b][columnStart]==null & rowStart-b!=rowEnd && pieces[rowEnd][columnEnd]==null){ // CHECKS THE UPPER ROW.
								   b++;	 
								  
								    }	
	   
		  }			  
       
		     rowX=rowX*(-1);   							
				
		    if(b<rowX || rowX==0 || b==0){
			isRookMovingUp=false;
			  System.out.println("This is  false"+" B is "+ b + " rowX is "+rowX);
         }
         else{
			isRookMovingUp=true;
			  System.out.println("This is true "+" B is "+ b+ " row X is "+rowX  );
         }	
	 	
		
  }	
 }

the code with the chesspiece object array. (i copied and pasted teh same algorithm i used in the other String array).
This code. doesnt work.!

public boolean piecesCollision(ChessPiece[][]pieces,int rowStart,int columnStart ,int columnEnd,int rowEnd) {
		
		

		
		
		boolean isRookMovingRight=false;
		boolean isRookMovingLeft=false;
		boolean isRookMovingDown=false;
		boolean isRookMovingUp=false;
       
		
		int b=0;
		int rowX=rowEnd-rowStart;
		
		int columnY=columnEnd-columnStart;
		   
		    System.out.println("rowX "+rowX);
		    System.out.println("columnY "+columnY);
		
		////////////////////////////////////////////////////////////////////////////////////////////////////////////
		if(columnY>0 & rowX==0){ // RIGHT SIDE (CHECK FOR NULL)
				  	  
			 
					
		  b=1;	
		  while(pieces[rowStart][columnStart+b]==null && columnStart+b!=columnEnd && pieces[rowEnd][columnEnd]==null){
						     b++;
						   
				 
		             }
		
		  System.out.println("B "+ b );
			
			   
			  
		    if(b<columnY || columnY==0 || b==0 ){
			isRookMovingRight=false;
			System.out.println("This is false "+ b+ " This is space "+ columnY);
         }
         else{
			isRookMovingRight=true;
			System.out.println("This is true "+ b+ " This is space "+ columnY);
         }	 // IF B SMALLER THAN THE DIFFERENCE BETWEEN COLUMNSTART & COLUMNEND (SPACESY) , GIVE FALSE. OTHERWISE GIVE TRUE.
		
		
		}

		
		//////////////////////////////////////////////////////////////////////////////////////////////////////
		
		
		
		
		if(columnY<0 & rowX==0){ // LEFT SIDE (CHECK FOR NULL)
						  	  
				
							  
		while(pieces[rowStart][columnStart-1-b]==null && columnStart-b!=columnEnd && pieces[rowEnd][columnEnd]==null){
						     b++;
						    
				  
							
			}
      			
		  
	
		columnY=columnY*(-1); 
		
		   if(b<columnY || columnY==0 || b==0 ){
				isRookMovingLeft=false;
				System.out.println("This is false "+ b+ " This is space "+ columnY);
		     }
		     else{
				isRookMovingLeft=true;
				System.out.println("This is true "+ b+ " This is space "+ columnY);
		     }			  
						  
		}		
					  
			

		
		
		
		//////////////////////////////////////////////////////////////////////////////////////////////////////////
		
		   if(columnY==0 & rowX>0){ // DOWN SIDE (CHECK FOR NULL)
			  	  
				 
				b=1;
			   while(pieces[rowStart+b][columnStart]==null && rowStart+b!=rowEnd && pieces[rowEnd][columnEnd]==null){ // CHECKS THE down ROW.
									   b++;						   
						}	
			  
			   
			    if(b<rowX || rowX==0 || b==0 ){
				isRookMovingDown=false;
				System.out.println("This is false "+ b+ " This is space "+ columnY);
	         }
	         else{
				isRookMovingDown=true;
				System.out.println("This is true "+ b+ " This is space "+ rowX);
	         }			
								  
			}	  
							  
		/////////////////////////////////////////////////////////////////////////////////////						  
		  if(columnY==0 & rowX<0){ // UP SIDE (CHECK FOR NULL)			  
			 // (array[columnStart-b]!=0 && array[columnStart-b]!=array[columnEnd]&& array[columnEnd]!=0 )	
		
	     while(pieces[rowStart-1-b][columnStart]==null & rowStart-b!=rowEnd && pieces[rowEnd][columnEnd]==null){ // CHECKS THE UPPER ROW.
								   b++;	 
								  
								    }	
	   
		  }			  
       
		     rowX=rowX*(-1);   							
				
		    if(b<rowX || rowX==0 || b==0){
			isRookMovingUp=false;
			  System.out.println("This is  false"+" B is "+ b + " rowX is "+rowX);
         }
         else{
			isRookMovingUp=true;
			  System.out.println("This is true "+" B is "+ b+ " row X is "+rowX  );
         }	
	 	
	 	return isRookMovingLeft || isRookMovingRight || isRookMovingUp || isRookMovingDown;
}	

}

here is its object array in the main class:

pieces[2][1]=new Pawn("Bpn1");
			   pieces[2][2]=new Pawn("Bpn2");
			   pieces[2][3]=new Pawn("Bpn3");
			   pieces[2][4]=new Pawn("Bpn4");
			   pieces[2][5]=new Pawn("Bpn5");
			   pieces[2][6]=new Pawn("Bpn6");
			   pieces[2][7]=new Pawn("Bpn7");
			   pieces[2][8]=new Pawn("Bpn8");
			   					  
			          pieces [1][1]=new Rook("BR1");
				  pieces [1][2]=new Knight("BN1");
				  pieces [1][3]=new Bishop("BB1");
				  pieces [1][4]=new King("BKing");
				  pieces [1][5]=new Queen("BQueen");
				  pieces [1][6]=new Bishop("BB2");
				  pieces [1][7]=new Knight("BN2");
				  pieces [1][8]=new Rook("BR2");		  
		  
				   pieces[7][1]=new Pawn("Wpn1");
				   pieces[7][2]=new Pawn("Wpn2");
				   pieces[7][3]=new Pawn("Wpn3");
				   pieces[7][4]=new Pawn("Wpn4");
				   pieces[7][5]=new Pawn("Wpn5");
				   pieces[7][6]=new Pawn("Wpn6");
				   pieces[7][7]=new Pawn("Wpn7");
				   pieces[7][8]=new Pawn("Wpn8");
				   	   	  
				      pieces [8][1]=new Rook("WR1");
				     pieces [8][2]=new Knight("WN1");
					  pieces [8][3]=new Bishop("WB1");
					  pieces [8][4]=new King("WKing");
					  pieces [8][5]=new Queen("WQueen");
					  pieces [8][6]=new Bishop("WB2");
					  pieces [8][7]=new Knight("WN2");
					  pieces [8][8]=new Rook("WR2");

Do you notice any differences that cause the mistake?

Here we go again:
"it doesnt work" is no use to me at all. We've discussed this before. Without a full description of the expected & actual results I can do nothing.

James i gave you the description on the page before. refer to it when you ask the same question again and again (it is in the green letterS).

Thanks.


i think i debugged this whole thing enough time. i cant go any longer, i must have someone who knows java well, to know where is my mistake,

OK. I'll leave you to find "someone who knows java well". Good luck.
Bye
J

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.