-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPawn.java
More file actions
33 lines (29 loc) · 861 Bytes
/
Copy pathPawn.java
File metadata and controls
33 lines (29 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author TARUN BHARDWAJ
*/
public class Pawn extends Pieces{
public Pawn(boolean isalive , int x , int y){
super(isalive,x,y);
}
@Override
public boolean isValid(Board board, int iniX, int iniY, int finalX, int finalY){
boolean check1=super.isValid(board, iniX, iniY, finalX, finalY);
if (check1==false)
return false;
int xshift=Math.abs(iniX-finalX);
int yshift=Math.abs(iniY-finalY);
if(yshift!=0)
return false;
if((iniY==1||iniY==6)&&xshift==1)
return true;
else if(xshift==2)
return true;
return false;
}
}