diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
index 3a3885e..c4c9543 100644
--- a/.idea/codeStyleSettings.xml
+++ b/.idea/codeStyleSettings.xml
@@ -1,6 +1,9 @@
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index ca9bc15..cde46ff 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,12 +1,12 @@
-
+
+
-
-
+
@@ -32,10 +32,10 @@
-
+
-
+
@@ -65,7 +65,7 @@
-
+
@@ -75,8 +75,8 @@
-
-
+
+
@@ -85,18 +85,18 @@
-
-
+
+
-
+
-
-
+
+
@@ -105,7 +105,7 @@
-
+
@@ -153,7 +153,6 @@
-
@@ -161,8 +160,9 @@
-
+
+
@@ -230,6 +230,9 @@
CoffeeScript
+
+ Control FlowPHP
+
Control flow issuesJavaScript
@@ -398,8 +401,8 @@
-
-
+
+
@@ -556,38 +559,44 @@
1458204604411
-
+
+ 1458207812223
+
+
+ 1458207812223
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -599,7 +608,7 @@
-
+
@@ -660,7 +669,8 @@
-
+
+
@@ -991,74 +1001,74 @@
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
diff --git a/src/Coffee/Map.php b/src/Coffee/Map.php
index e97fea7..e70391a 100644
--- a/src/Coffee/Map.php
+++ b/src/Coffee/Map.php
@@ -21,7 +21,10 @@ class Map {
*/
private $description = [];
-// private $visited = [];
+ /**
+ * @var array
+ */
+ private $visited = [];
/**
* @var int
@@ -58,17 +61,17 @@ class Map {
}
/**
- * @return int
+ * @param $row
+ * @param $column
+ * @return bool
*/
- public function getHeight() {
- return $this->height;
- }
+ public function visitPosition($row, $column) {
+ if ($this->isValidPosition($row, $column)) {
+ $this->visited[$row][$column] = true;
+ return true;
+ }
- /**
- * @return int
- */
- public function getWidth() {
- return $this->width;
+ return false;
}
/**
@@ -90,12 +93,17 @@ class Map {
}
/**
- * @param $description
* @return int
*/
- private function calculateMapHeight($description) {
- // Count the level 1 array elements
- return count($description);
+ public function getHeight() {
+ return $this->height;
+ }
+
+ /**
+ * @return int
+ */
+ public function getWidth() {
+ return $this->width;
}
/**
@@ -115,9 +123,26 @@ class Map {
return $widestRow;
}
-// public function visitPosition($row, $column) {
-//
-//
-// }
+ /**
+ * @param $description
+ * @return int
+ */
+ private function calculateMapHeight($description) {
+ // Count the level 1 array elements
+ return count($description);
+ }
+
+ /**
+ * @param $row
+ * @param $column
+ * @return bool
+ */
+ public function isVisitedPosition($row, $column) {
+ if (!isset($this->visited[$row][$column])) {
+ return false;
+ }
+
+ return ($this->visited[$row][$column] == true);
+ }
}
\ No newline at end of file
diff --git a/tests/MapTest.php b/tests/MapTest.php
index 42ff466..ebc85ea 100644
--- a/tests/MapTest.php
+++ b/tests/MapTest.php
@@ -65,25 +65,31 @@ class MapTest extends \PHPUnit_Framework_TestCase {
$map = new Map($description);
$this->assertFalse($map->isValidPosition(3, 4));
}
-// public function testTileLiesOnTable() {
-// $tableMap = [
-// [1, 0],
-// [0, 1],
-// ];
-//
-// $table = new Table($tableMap);
-// $tile = new Tile(0, 0);
-// $this->assertTrue($table->couldContainTile($tile));
-// }
-//
-// public function testTileLiesOutsideTable() {
-// $tableMap = [
-// [1, 0],
-// [0, 1],
-// ];
-//
-// $table = new Table($tableMap);
-// $tile = new Tile(2, 1);
-// $this->assertFalse($table->couldContainTile($tile));
-// }
+
+ public function testVisitedPosition() {
+ $description = [
+ [0, 1, 0, 1],
+ [1, 0, 0, 0],
+ [0, 0, 0, 1],
+ [0, 0, 0, 1]
+ ];
+
+ $map = new Map($description);
+ $map->visitPosition(0, 0);
+ $this->assertTrue($map->isVisitedPosition(0, 0));
+ }
+
+ public function testNotVisitedPosition() {
+ $description = [
+ [0, 1, 0, 1],
+ [1, 0, 0, 0],
+ [0, 0, 0, 1],
+ [0, 0, 0, 1]
+ ];
+
+ $map = new Map($description);
+ $map->visitPosition(0, 0);
+ $this->assertFalse($map->isVisitedPosition(4, 0));
+ }
+
}
diff --git a/tests/TileTest.php b/tests/TileTest.php
index 78094b1..18061a7 100644
--- a/tests/TileTest.php
+++ b/tests/TileTest.php
@@ -7,8 +7,6 @@ require __DIR__ . '/../vendor/autoload.php';
class TileTest extends \PHPUnit_Framework_TestCase {
-
-
public function testTheSameX() {
$tileA = new Tile(2, 2);
$tileB = new Tile(2, 2);