} } public void paintComponent(Graphics g){ } public void drawBoard(Graphics g){ for(int i=0;i g.drawLine(3*interval+initX, initY, 5*interval+initX,2*interval+initY );//画斜线 initY); g.drawLine(3*interval+initY, 2*interval+initY,5*interval+initX, g.drawLine(3*interval+initX,(yPoint-1)*interval+initY,5*interval+initX, (yPoint-3)*interval+initY); g.drawLine(3*interval+initX,(yPoint-3)*interval+initY,5*interval+initX, (yPoint-1)*interval+initY); } import java.sql.Statement; public class ChessRule { private Point startPoint; private Point endPoint; private int interval; private int initX; private int initY; Point[][] choicePoint; public ChessRule(Point startPoint,Point endPoint,int interval,int initX,int initY,Point[][] choicePoint){ } private boolean isPoint(){ if(startPoint!=null&&endPoint!=null){ this.startPoint=startPoint; this.endPoint=endPoint; this.interval=interval; this.initX=initX; this.initY=initY; this.choicePoint=choicePoint; if(endPoint.hasChess){ if(startPoint.getChess().getPlayer().equals(endPoint.getChess().getPlayer())){ } private boolean checkRule(String name){ if(startPoint.getPlaceX()==endPoint.getPlaceX()||startPoint.getPlaceY()==enif(name.equals(\车\ } return false; } return true; } return false; dPoint.getPlaceY()){ if(Math.abs(startPoint.getPlaceX()-endPoint.getPlaceX())==2*interval&&Math. } if(name.equals(\马\ } return false; if(hasBlock(name)==0){ } return true; abs(startPoint.getPlaceY()-endPoint.getPlaceY())==interval) } if(Math.abs(startPoint.getPlaceX()-endPoint.getPlaceX())==interval&&Math.abs(st { if(hasBlock(name)==0){ return true; } artPoint.getPlaceY()-endPoint.getPlaceY())==2*interval) } if(name.equals(\象\ if(startPoint.getChess().getPlayer().equals(\ } if(startPoint.getChess().getPlayer().equals(\ } if(endPoint.getPlaceY()<5*interval+initY){ } return false; if(endPoint.getPlaceY()>4*interval+initY){ } return false; { } if(hasBlock(name)==0){ } return true; if(Math.abs(startPoint.getPlaceX()-endPoint.getPlaceX())==2*interval&&Math.abs(startPoint.getPlaceY()-endPoint.getPlaceY())==2*interval){ } if(name.equals(\兵\ if(endPoint.getPlaceY() if(endPoint.getPlaceX()==startPoint.getPlaceX()&&Math.abs(endPoint.getPlaceY()-startPoint.getPlaceY())==interval){ } if(startPoint.getPlaceY()>4*interval+initY){return true; if(endPoint.getPlaceY()==startPoint.getPlaceY()&&Math.abs(endPoint.getPlaceX()-startPoint.getPlaceX())==interval){ } if(name.equals(\卒\ if(endPoint.getPlaceY()>startPoint.getPlaceY()){ }return false; } } return true; if(endPoint.getPlaceX()==startPoint.getPlaceX()&&Math.abs(startPoint.getPlaceY()-endPoint.getPlaceY())==interval){ } if(startPoint.getPlaceY()<5*interval+initY){ return true; if(endPoint.getPlaceY()==startPoint.getPlaceY()&&Math.abs(startPoint.getPlaceX()-endPoint.getPlaceX())==interval){ return true;} } } if(name.equals(\士\ if(startPoint.getChess().getPlayer().equals(\ if(endPoint.getPlaceX()<3*interval+initX||endPoint.getPlaceY()>2*interval+initY){ } return false;