日期:2019.5.8 

博客期:071

星期三

  我在这里只写出基本的象棋构建代码模型,即基本的DOC窗口实现程度的算法,还有,对不起,没有棋局记录等功能、没有其他的界面就是简单的逻辑结构!

  (这个其实也可以算是每周总结的一部分啦!)

 1 package basic;
 2 
 3 public class Chess {
 4     //所属
 5     /*true为红方,false为黑方*/
 6     protected boolean aim;
 7     //名称
 8     protected ChessKind name;
 9     //位置
10     protected TableSeat tableseat;
11     //基本方法
12     public boolean isAim() {
13         return aim;
14     }
15     public void setAim(boolean aim) {
16         this.aim = aim;
17     }
18     public ChessKind getName() {
19         return name;
20     }
21     public void setName(ChessKind name) {
22         this.name = name;
23     }
24     public TableSeat getTableseat() {
25         return tableseat;
26     }
27     public void setTableseat(TableSeat tableseat) {
28         this.tableseat = tableseat;
29     }
30     //构造
31     public Chess(boolean aim, ChessKind name, TableSeat tableseat) {
32         super();
33         this.aim = aim;
34         this.name = name;
35         this.tableseat = new TableSeat(tableseat);
36     }
37     //其他方法
38     /*改变所属方*/
39     public void changeAim(){
40         this.aim = !this.aim;
41     }
42     /*上下调换*/
43     public void changeUpAndDown(){
44         this.tableseat.y = 10-tableseat.y;
45     }
46     /*左右调换*/
47     public void changeLeftAndRight(){
48         this.tableseat.x = 11-tableseat.x;
49     }
50     public void display(){
51         System.out.println("X:"+tableseat.x+"\tY:"+tableseat.y+"\tK:"+(ChessTable.changeTo(name,aim))+"\tM:"+(aim?"红方":"黑方"));
52     }
53 }
Chess.java

相关文章: