浏览代码

rowscolumns

Seth 6 年前
父节点
当前提交
bde774205b
共有 1 个文件被更改,包括 18 次插入2 次删除
  1. 18
    2
      src/main/java/rocks/zipcode/io/quiz3/arrays/TicTacToe.java

+ 18
- 2
src/main/java/rocks/zipcode/io/quiz3/arrays/TicTacToe.java 查看文件

@@ -1,19 +1,35 @@
1 1
 package rocks.zipcode.io.quiz3.arrays;
2 2
 
3
+import java.util.stream.IntStream;
4
+
3 5
 /**
4 6
  * @author leon on 09/12/2018.
5 7
  */
6 8
 public class TicTacToe {
9
+    private String[][] board;
7 10
 
8 11
     public TicTacToe(String[][] board) {
12
+        this.board = board;
13
+    }
14
+
15
+    public TicTacToe(){
16
+
9 17
     }
10 18
 
11 19
     public String[] getRow(Integer value) {
12
-        return null;
20
+        String[] row = new String[board[0].length];
21
+        for (int i =0; i< row.length; i++){
22
+            row[i] = board[value][i];
23
+        }
24
+        return row;
13 25
     }
14 26
 
15 27
     public String[] getColumn(Integer value) {
16
-        return null;
28
+        String[] column = new String[board[0].length];
29
+        for (int i =0; i< column.length; i++){
30
+            column[i] = board[i][value];
31
+        }
32
+        return column;
17 33
     }
18 34
 
19 35
     public Boolean isRowHomogenous(Integer rowIndex) {