Browse Source

update example solution to match new test expectations

Corey McCandless 6 years ago
parent
commit
053996abe2
No account linked to committer's email
1 changed files with 5 additions and 11 deletions
  1. 5
    11
      exercises/go-counting/.meta/src/reference/java/GoCounting.java

+ 5
- 11
exercises/go-counting/.meta/src/reference/java/GoCounting.java View File

@@ -127,22 +127,16 @@ class GoCounting {
127 127
 	}
128 128
 	
129 129
 	HashMap<String, Set<Point>> getTerritories() {
130
-		HashMap<String, Set<Point>> territories = new HashMap<String, Set<Point>>();
130
+		HashMap<Player, Set<Point>> territories = new HashMap<Player, Set<Point>>();
131 131
 		
132
-		territories.put("WHITE", new HashSet<Point>());
133
-		territories.put("BLACK", new HashSet<Point>());
134
-		territories.put("NONE", new HashSet<Point>());
132
+		territories.put(Player.WHITE, new HashSet<Point>());
133
+		territories.put(Player.BLACK, new HashSet<Point>());
134
+		territories.put(Player.NONE, new HashSet<Point>());
135 135
 		
136 136
 		for (int i = 0; i < board[0].length; i++) {
137 137
 			for (int j = 0; j < board.length; j++) {
138 138
 				if (board[j][i] == Player.NONE) {
139
-					if (getTerritoryOwner(j, i) == Player.NONE) {
140
-						territories.get("NONE").add(new Point(j, i));
141
-					} else if (getTerritoryOwner(j, i) == Player.BLACK) {
142
-						territories.get("BLACK").add(new Point(j, i));
143
-					} else {
144
-						territories.get("WHITE").add(new Point(j, i));
145
-					}
139
+					territories.get(getTerritoryOwner(j, i)).add(new Point(j, i));
146 140
 				}
147 141
 			}
148 142
 		}