Bug 234

Summary: Lack of initializing of variables before a new while loop
Product: CS3343 group25 chess game Reporter: Andy <dotafterfootball>
Component: chess gameAssignee: HUANG Xiaofeng <xhuang227-c>
Status: CONFIRMED ---    
Severity: enhancement    
Priority: ---    
Version: unspecified   
Hardware: PC   
OS: Mac OS   

Description Andy 2017-11-30 00:18:58 HKT
private boolean checkDiagonal(){//for bishop and queen 
		int x = king_x;
		int y = king_y;
		
		while(x<7 && y<7){//northEast
			x++;
			y++;
			Piece temp= board.getPiece(x, y);
			if(temp!=null){
				if(temp.getColor()==color)
					return false;
				else
					if(temp instanceof Bishop||temp instanceof Queen){
						return true;
					}
			}
			
		}
		
		while(x>0 && y>0){}
			...
		}
	}
X and y have not been initialized before the second while loop, which will result in getting the wrong position information of king.