homework-06

1。解释playprev函数的功能

(1)把gm的子去除后转移gm的mark到之前的棋子并设置之前棋子为重画

(2)如果当前棋子有吃掉,需要把吃掉的都重画

(3)对吃掉的棋子采用迭代器,遍历数字设置nokilled和setstorn

(4)重画

 

public void playPrev(GoMove gm)
        {
           int i = gm.Point.X;
            int j = gm.Point.Y;
            Grid[i,j].removeStone();
            m_gmLastMove = gameTree.peekPrev();
           if (m_gmLastMove != null)
                Grid[m_gmLastMove.Point.X,m_gmLastMove.Point.Y].setUpdated();
           if (gm.DeadGroup != null)          {
                System.Collections.IEnumerator myEnumerator = gm.DeadGroup.GetEnumerator();
                while (myEnumerator.MoveNext())
                {
                     Point p;    
                    p = (Point)myEnumerator.Current;
                    Grid[p.X,p.Y].setNoKilled();
                    Grid[p.X,p.Y].setStone(nextTurn(gm.Color));
               }
            }
           optRepaint();
           return; 
        }

 点评一下代码的不足之处:

1.没有错误的处理,若是程序有bug的话不知在何处抛出异常

2.函数之间的逻辑结构不够清晰,众多函数和变量仅仅出现一次,可以采取更好的方式改写。

3.程序在编写之前没有经过系统的设计,导致类之间的关系很混乱。

4.直接从java一直到C#真的大丈夫?

程序注释部分在github中,博客中就不再体现。

posted on 2013-11-25 08:05  wwtbuaa  阅读(130)  评论(0编辑  收藏  举报