东北大学软件学院2021-2022软件需求设计与分析五子棋作业

天翼云盘链接: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();
				}
             }
		}
	}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

@triswang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值