diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1144cab..e898004 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,12 +4,10 @@ - + - + - - @@ -38,8 +36,8 @@ - - + + @@ -48,8 +46,8 @@ - - + + @@ -58,8 +56,8 @@ - - + + @@ -78,7 +76,7 @@ - + @@ -88,7 +86,7 @@ - + @@ -105,10 +103,10 @@ - + - + @@ -125,10 +123,10 @@ - + - + @@ -185,11 +183,11 @@ - - - + + + @@ -483,7 +481,7 @@ - + @@ -753,47 +751,68 @@ 1458499267612 - + + 1458499688945 + + + 1458499688945 + + + 1458500376151 + + + 1458500376151 + + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - - + + @@ -803,7 +822,7 @@ - + @@ -829,9 +848,8 @@ + - - @@ -855,7 +873,9 @@ - + + + @@ -868,11 +888,16 @@ 107 + + file://$PROJECT_DIR$/index.php + 19 + + - + @@ -1189,14 +1214,6 @@ - - - - - - - - @@ -1205,26 +1222,26 @@ - + - - + + - + - - + + - + - - + + @@ -1237,34 +1254,42 @@ + + + + + + + + - - + + - - + + - + - - + + - + - - + + diff --git a/index.php b/index.php index ddeb7c9..35bdc53 100644 --- a/index.php +++ b/index.php @@ -5,24 +5,28 @@ namespace Coffee; require __DIR__ . '/vendor/autoload.php'; try { -// $map = new Map([ -// [0, 1, 0, 1], -// [1, 0, 0, 0], -// [0, 0, 0, 1], -// [0, 0, 1, 1] -// ]); -// -// $table = new Table($map); -// -// $table->getSpots()[0]->getPositions()[0]-> -// -// foreach ($map->describedByArray() as $item) { -// ; -// } -// -// $output = new Output($table); + $map = new Map([ + [0, 1, 0, 1], + [1, 0, 0, 0], + [0, 0, 0, 1], + [0, 0, 1, 1] + ]); + + $table = new Table($map); + + echo ''; + foreach ($map->describedByArray() as $rowIndex => $row) { + echo '' . "\n"; + foreach ($row as $columnIndex => $column) { + $position = new Position($rowIndex + 1, $columnIndex + 1); + echo '' . $table->getSpotIndexByPosition($position) . '' . "\n"; + } + echo '' . "\n"; + } + echo ''; } catch (\Exception $e) { + // TODO: provide more information, like the file:line for example echo 'Caught exception: ' . $e->getMessage() . "\n"; } diff --git a/src/Coffee/Table.php b/src/Coffee/Table.php index 7fdcf0e..eb5ecb9 100644 --- a/src/Coffee/Table.php +++ b/src/Coffee/Table.php @@ -68,7 +68,7 @@ class Table { /** * @param Position $searchedPosition - * @return int|null + * @return int|string */ public function getSpotIndexByPosition(Position $searchedPosition) { // Linear search @@ -81,7 +81,7 @@ class Table { } } - return null; + return ''; } /**