Skip to content

Commit

Permalink
新增注释
Browse files Browse the repository at this point in the history
注释
  • Loading branch information
TedHacker committed Jan 23, 2017
1 parent f918b5f commit a8db765
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions TheGameOfLife/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.classpath
.project
.idea/
*.iml
target/
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@

@Service
public class TheGameOfLifeService {
//方向数组
private int[] direct = {-1, 0, 1};

/**
* 给定阵列和坐标,计算坐标点的邻居存活数量
* @param now 细胞阵列
* @param x 横坐标
* @param y 纵坐标
* @return
*/
private int countLiveNeighbor(CellularArray now, int x, int y) {
int count = 0;
for (int i = 0; i < 3; ++i) {
Expand All @@ -25,6 +33,11 @@ private int countLiveNeighbor(CellularArray now, int x, int y) {
return count;
}

/**
* 给定细胞阵列,生成下一代的细胞阵列
* @param now 细胞阵列
* @return
*/
public CellularArray generate(CellularArray now) {
if (null == now) {
return null;
Expand All @@ -46,6 +59,11 @@ public CellularArray generate(CellularArray now) {
return next;
}

/**
* 给定细胞阵列,产生随机结果
* @param cellularArray 细胞阵列
* @return
*/
public CellularArray randInit(CellularArray cellularArray) {
if (null == cellularArray) return null;
Random r = new Random();
Expand All @@ -59,6 +77,11 @@ public CellularArray randInit(CellularArray cellularArray) {
return cellularArray;
}

/**
* 给定细胞阵列,产生初始化结果
* @param cellularArray
* @return
*/
public CellularArray emptyInit(CellularArray cellularArray) {
if (null == cellularArray) return null;
for (int i = 0; i < cellularArray.getRow(); ++i) {
Expand Down

0 comments on commit a8db765

Please sign in to comment.