天翼云盘链接:https://cloud.189.cn/t/EzAjYbre6Fjq (访问码:8hqf)
写在前面:拖延了大半年,趁着最近实训传一下。软需改成考试课以后具体形式还是有点懵,就随便分享一下吧。根据迭代开发一共出了三版(FiveChess1.0,2.0和3.0)每次根据具体需求不同都有不同的改动,现在只传了第三版,到最后测着测着开始疯狂报错,半年多前的代码没有啥修改的欲望,大伙看一乐吧。
登录界面
第一版主界面(跟上个作业相似 都是缝合的)
第三版主界面(看着返璞归真了,实际上才是软需这门课的重点,做的花哨屁用没有)
第一版棋局记录界面
第三版棋局记录界面
棋局回放
想要发布说内容质量较低,所以贴点代码,展示一下棋局回放的具体代码,算是比较难想的一部分。
public void paint(Graphics g) {
int[][] allChess = new int[19][19];
ImageIcon icon = new ImageIcon("jp.png");
Image jp = icon.getImage();
//画棋盘
g.drawImage(jp, 0, 0,569, 598 ,icon.getImageObserver());
for (int colum = 58; colum < 540; colum = colum + 30) {
g.drawLine(38, colum, 517, colum);
}
for (int rand = 38; rand < 540; rand = rand + 30) {
g.drawLine(rand, 58, rand, 540);
}
g.fillOval(273, 293, 10, 10);
//把这局对局中需要的棋子提取出来
ArrayList<Piece> allPiece = (ArrayList<Piece>) this.getPiece();
ArrayList<Piece> neededPiece = new ArrayList<Piece>();
for(Piece p:allPiece) {
if(p.getBoardnumber()==number) {
neededPiece.add(p);
}
}
//画棋子
for(int i = 0;i<neededPiece.size();i++) {
int tempX=neededPiece.get(i).getX()*30+38;
int tempY=neededPiece.get(i).getY()*30+58;
if(i%2==0) {
g.setColor(Color.black);
}else {
g.setColor(Color.white);
}
g.fillOval(tempX-13,tempY-13,25,25);
if(i%2==0) {
g.setColor(Color.white);
g.drawString(String.valueOf(i+1), tempX, tempY);
}else {
g.setColor(Color.BLACK);
g.drawString(String.valueOf(i+1), tempX, tempY);
}
//提取下棋的时间,获得时间间隔,让线程sleep
if(i+1<neededPiece.size()) {
Thread.currentThread();
try {
long time1 = neededPiece.get(i+1).getDate().getTime();
long time2 = neededPiece.get(i).getDate().getTime();
Thread.sleep(time1 - time2);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}