Modify Table so it now extends Map

master
Peter Babič 8 years ago
parent 70f40a1cfd
commit 1880ebe1aa
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 294
      .idea/workspace.xml
  2. 8
      index.php
  3. 49
      src/Coffee/Map.php
  4. 19
      src/Coffee/Table.php
  5. 11
      tests/Coffee/MapTest.php
  6. 52
      tests/Coffee/TableTest.php

@ -4,10 +4,12 @@
<option name="ANALYZE_TEST_SOURCES" value="false" />
</component>
<component name="ChangeListManager">
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Implement Tile.getSpotNumber">
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Modify Table so it now extends Map">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Coffee/Map.php" afterPath="$PROJECT_DIR$/src/Coffee/Map.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/index.php" afterPath="$PROJECT_DIR$/index.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Coffee/Table.php" afterPath="$PROJECT_DIR$/src/Coffee/Table.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/Coffee/MapTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/MapTest.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/Coffee/TableTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
</list>
<ignored path="coffeetable.iws" />
<ignored path=".idea/workspace.xml" />
@ -36,58 +38,28 @@
<file leaf-file-name="index.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-12.666667">
<caret line="22" column="9" selection-start-line="22" selection-start-column="9" selection-end-line="22" selection-end-column="9" />
<state vertical-scroll-proportion="-11.333333">
<caret line="17" column="19" selection-start-line="17" selection-start-column="19" selection-end-line="17" selection-end-column="19" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Table.php" pinned="false" current-in-tab="true">
<file leaf-file-name="Table.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="3.7190082">
<caret line="100" column="59" selection-start-line="100" selection-start-column="59" selection-end-line="100" selection-end-column="59" />
<state vertical-scroll-proportion="10.148149">
<caret line="38" column="42" selection-start-line="38" selection-start-column="42" selection-end-line="38" selection-end-column="42" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="TableTest.php" pinned="false" current-in-tab="false">
<file leaf-file-name="TableTest.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/tests/Coffee/TableTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-23.037037">
<caret line="111" column="28" selection-start-line="111" selection-start-column="28" selection-end-line="111" selection-end-column="28" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Spot.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-33.333332">
<caret line="55" column="23" selection-start-line="55" selection-start-column="23" selection-end-line="55" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="SpotTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/SpotTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-13.407408">
<caret line="25" column="0" selection-start-line="25" selection-start-column="0" selection-end-line="25" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Position.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-116.666664">
<caret line="175" column="23" selection-start-line="175" selection-start-column="23" selection-end-line="175" selection-end-column="23" />
<state vertical-scroll-proportion="2.8636363">
<caret line="119" column="34" selection-start-line="119" selection-start-column="34" selection-end-line="119" selection-end-column="34" />
<folding />
</state>
</provider>
@ -96,8 +68,8 @@
<file leaf-file-name="Map.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="14.740741">
<caret line="71" column="0" selection-start-line="71" selection-start-column="0" selection-end-line="71" selection-end-column="0" />
<state vertical-scroll-proportion="-5.3333335">
<caret line="8" column="32" selection-start-line="8" selection-start-column="32" selection-end-line="8" selection-end-column="32" />
<folding />
</state>
</provider>
@ -106,28 +78,8 @@
<file leaf-file-name="MapTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-60.0">
<caret line="90" column="0" selection-start-line="90" selection-start-column="0" selection-end-line="90" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Tile.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-76.666664">
<caret line="115" column="0" selection-start-line="115" selection-start-column="0" selection-end-line="115" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="TileTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-15.037037">
<caret line="43" column="55" selection-start-line="43" selection-start-column="55" selection-end-line="43" selection-end-column="55" />
<state vertical-scroll-proportion="-8.296296">
<caret line="17" column="0" selection-start-line="17" selection-start-column="0" selection-end-line="17" selection-end-column="0" />
<folding />
</state>
</provider>
@ -169,7 +121,6 @@
<option value="$PROJECT_DIR$/tests/SpotTest.php" />
<option value="$PROJECT_DIR$/tests/TileTest.php" />
<option value="$PROJECT_DIR$/phpunit.xml" />
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Map.php" />
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Tile.php" />
<option value="$PROJECT_DIR$/src/Coffee/Position.php" />
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Spot.php" />
@ -180,14 +131,16 @@
<option value="$PROJECT_DIR$/tests/Coffee/OutputTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Spot.php" />
<option value="$PROJECT_DIR$/tests/Coffee/PositionTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
<option value="$PROJECT_DIR$/index.php" />
<option value="$PROJECT_DIR$/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/tests/Coffee/SpotTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TileTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Tile.php" />
<option value="$PROJECT_DIR$/tests/Coffee/MapTest.php" />
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Map.php" />
<option value="/usr/share/nginx/html/coffeetable/tests/Coffee/TableTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Map.php" />
<option value="$PROJECT_DIR$/index.php" />
<option value="$PROJECT_DIR$/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/tests/Coffee/MapTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
</list>
</option>
</component>
@ -775,38 +728,56 @@
<option name="project" value="LOCAL" />
<updated>1458504793092</updated>
</task>
<option name="localTasksCounter" value="40" />
<task id="LOCAL-00040" summary="Implement Tile.getSpotNumber">
<created>1458505048918</created>
<option name="number" value="00040" />
<option name="project" value="LOCAL" />
<updated>1458505048918</updated>
</task>
<task id="LOCAL-00041" summary="Modify Table so it now extends Map">
<created>1458506640439</created>
<option name="number" value="00041" />
<option name="project" value="LOCAL" />
<updated>1458506640439</updated>
</task>
<task id="LOCAL-00042" summary="Modify Table so it now extends Map">
<created>1458506775285</created>
<option name="number" value="00042" />
<option name="project" value="LOCAL" />
<updated>1458506775285</updated>
</task>
<option name="localTasksCounter" value="43" />
<servers />
</component>
<component name="TestHistory">
<history-entry file="Tests - 2016.03.20 at 19h 47m 37s.xml">
<history-entry file="Tests - 2016.03.20 at 21h 34m 11s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.20 at 19h 48m 32s.xml">
<history-entry file="Tests - 2016.03.20 at 21h 36m 37s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.20 at 19h 56m 06s.xml">
<history-entry file="Tests - 2016.03.20 at 21h 36m 41s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.20 at 19h 56m 46s.xml">
<history-entry file="Tests - 2016.03.20 at 21h 40m 04s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.20 at 19h 58m 56s.xml">
<history-entry file="Tests - 2016.03.20 at 21h 40m 27s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.20 at 21h 05m 30s.xml">
<history-entry file="Tests - 2016.03.20 at 21h 41m 42s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.20 at 21h 05m 46s.xml">
<history-entry file="Tests - 2016.03.20 at 21h 43m 04s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.20 at 21h 05m 52s.xml">
<history-entry file="Tests - 2016.03.20 at 21h 45m 38s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.20 at 21h 06m 41s.xml">
<history-entry file="Tests - 2016.03.20 at 21h 46m 06s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.20 at 21h 10m 38s.xml">
<history-entry file="Tests - 2016.03.20 at 21h 51m 45s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
</component>
@ -828,7 +799,7 @@
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32917705" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="12" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32917705" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32917705" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32917705" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32668328" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" x="0" y="355" width="1446" height="188" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24964234" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
@ -862,7 +833,6 @@
<component name="VcsManagerConfiguration">
<option name="CHECK_NEW_TODO" value="false" />
<option name="USE_COMMIT_MESSAGE_MARGIN" value="true" />
<MESSAGE value="Rename Tile to Position" />
<MESSAGE value="Move tests to separate namespaced directory" />
<MESSAGE value="Implemet Tile extends Position" />
<MESSAGE value="Decouple Map and Position" />
@ -887,7 +857,8 @@
<MESSAGE value="Implement Table.getSpotIndexByPosition" />
<MESSAGE value="Present the first valid output of the namespace Coffee" />
<MESSAGE value="Implement Tile.getSpotNumber" />
<option name="LAST_COMMIT_MESSAGE" value="Implement Tile.getSpotNumber" />
<MESSAGE value="Modify Table so it now extends Map" />
<option name="LAST_COMMIT_MESSAGE" value="Modify Table so it now extends Map" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
<option name="REARRANGE_BEFORE_PROJECT_COMMIT" value="true" />
@ -895,21 +866,21 @@
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="php">
<url>file://$PROJECT_DIR$/tests/Coffee/TableTest.php</url>
<line>107</line>
<option name="timeStamp" value="40" />
</line-breakpoint>
<line-breakpoint enabled="true" type="php">
<url>file://$PROJECT_DIR$/index.php</url>
<line>19</line>
<option name="timeStamp" value="43" />
</line-breakpoint>
<line-breakpoint enabled="true" type="php">
<url>file://$PROJECT_DIR$/tests/Coffee/TableTest.php</url>
<line>16</line>
<option name="timeStamp" value="44" />
</line-breakpoint>
</breakpoints>
<breakpoints-dialog>
<breakpoints-dialog />
</breakpoints-dialog>
<option name="time" value="44" />
<option name="time" value="45" />
</breakpoint-manager>
<watches-manager>
<configuration name="PhpLocalRunConfigurationType">
@ -923,30 +894,6 @@
</watches-manager>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/tests/Coffee/SpotTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="25" column="0" selection-start-line="25" selection-start-column="0" selection-end-line="25" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="175" column="23" selection-start-line="175" selection-start-column="23" selection-end-line="175" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="57" column="12" selection-start-line="57" selection-start-column="12" selection-end-line="57" selection-end-column="64" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
@ -1120,13 +1067,6 @@
</state>
</provider>
</entry>
<entry file="file:///usr/share/nginx/html/coffeetable/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.47678572">
<caret line="45" column="67" selection-start-line="45" selection-start-column="51" selection-end-line="45" selection-end-column="67" />
</state>
</provider>
</entry>
<entry file="file:///usr/share/nginx/html/coffeetable/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.46964285">
@ -1141,20 +1081,6 @@
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestResult.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.4074073">
<caret line="846" column="0" selection-start-line="846" selection-start-column="0" selection-end-line="846" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestSuite.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.740741">
<caret line="734" column="0" selection-start-line="734" selection-start-column="0" selection-end-line="734" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/Assert.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.2767857">
@ -1211,14 +1137,6 @@
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestCase.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.31893003">
<caret line="985" column="0" selection-start-line="985" selection-start-column="0" selection-end-line="985" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-1.2592592">
@ -1251,58 +1169,114 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/TableTest.php">
<entry file="file:///usr/share/nginx/html/coffeetable/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-23.037037">
<caret line="111" column="28" selection-start-line="111" selection-start-column="28" selection-end-line="111" selection-end-column="28" />
<state vertical-scroll-proportion="0.35185185">
<caret line="39" column="0" selection-start-line="39" selection-start-column="0" selection-end-line="39" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.php">
<entry file="file:///usr/share/nginx/html/coffeetable/tests/Coffee/TableTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-12.666667">
<caret line="22" column="9" selection-start-line="22" selection-start-column="9" selection-end-line="22" selection-end-column="9" />
<state vertical-scroll-proportion="0.5740741">
<caret line="31" column="0" selection-start-line="31" selection-start-column="0" selection-end-line="31" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<entry file="file://$PROJECT_DIR$/vendor/composer/ClassLoader.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-76.666664">
<caret line="115" column="0" selection-start-line="115" selection-start-column="0" selection-end-line="115" selection-end-column="0" />
<state vertical-scroll-proportion="-8.333333">
<caret line="302" column="0" selection-start-line="302" selection-start-column="0" selection-end-line="302" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php">
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestResult.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-60.0">
<caret line="90" column="0" selection-start-line="90" selection-start-column="0" selection-end-line="90" selection-end-column="0" />
<state vertical-scroll-proportion="-6.3333335">
<caret line="709" column="0" selection-start-line="709" selection-start-column="0" selection-end-line="709" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/TextUI/TestRunner.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="15.666667">
<caret line="433" column="0" selection-start-line="433" selection-start-column="0" selection-end-line="433" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestSuite.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.037037037">
<caret line="734" column="0" selection-start-line="734" selection-start-column="0" selection-end-line="734" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestCase.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.33333334">
<caret line="802" column="0" selection-start-line="802" selection-start-column="0" selection-end-line="802" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="14.740741">
<caret line="71" column="0" selection-start-line="71" selection-start-column="0" selection-end-line="71" selection-end-column="0" />
<state vertical-scroll-proportion="-5.3333335">
<caret line="8" column="32" selection-start-line="8" selection-start-column="32" selection-end-line="8" selection-end-column="32" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-8.296296">
<caret line="17" column="0" selection-start-line="17" selection-start-column="0" selection-end-line="17" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-11.333333">
<caret line="17" column="19" selection-start-line="17" selection-start-column="19" selection-end-line="17" selection-end-column="19" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="10.148149">
<caret line="38" column="42" selection-start-line="38" selection-start-column="42" selection-end-line="38" selection-end-column="42" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-76.666664">
<caret line="115" column="0" selection-start-line="115" selection-start-column="0" selection-end-line="115" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-116.666664">
<state vertical-scroll-proportion="3.368984">
<caret line="175" column="23" selection-start-line="175" selection-start-column="23" selection-end-line="175" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<entry file="file://$PROJECT_DIR$/tests/Coffee/TableTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="3.7190082">
<caret line="100" column="59" selection-start-line="100" selection-start-column="59" selection-end-line="100" selection-end-column="59" />
<state vertical-scroll-proportion="2.8636363">
<caret line="119" column="34" selection-start-line="119" selection-start-column="34" selection-end-line="119" selection-end-column="34" />
<folding />
</state>
</provider>

@ -5,21 +5,21 @@ namespace Coffee;
require __DIR__ . '/vendor/autoload.php';
try {
$map = new Map([
$map = [
[0, 1, 0, 1],
[1, 0, 0, 0],
[0, 0, 0, 1],
[0, 0, 1, 1]
]);
];
$table = new Table($map);
echo '<table>';
foreach ($map->describedByArray() as $rowIndex => $row) {
foreach ($table->getDescription() as $rowIndex => $row) {
echo '<tr>' . "\n";
foreach ($row as $columnIndex => $column) {
$position = new Position($rowIndex + 1, $columnIndex + 1);
echo '<td>' . $table->getSpotIndexByPosition($position) . '</td>' . "\n";
echo '<td>' . $table->getSpotNumberByPosition($position) . '</td>' . "\n";
}
echo '</tr>' . "\n";
}

@ -2,15 +2,11 @@
namespace Coffee;
/**
* Class Map
*
* @package Coffee
*/
/**
* Class Map
*
* @package Coffee
* TODO: make class Map abstract
*/
class Map {
@ -28,6 +24,11 @@ class Map {
*/
private $width = 0;
/**
* @var array[]
*/
private $description = [];
/**
* Map constructor.
*
@ -40,27 +41,31 @@ class Map {
throw new \Exception('The Coffee Table map could not be loaded.');
}
$height = 0;
$width = 0;
$this->description = $description;
// This data processing could be written more read-ably in multiple cycles / private methods,
// but at a cost of reduced performance (minor).
$width = 0;
foreach ($description as $rowIndex => $row) {
foreach ($row as $columnIndex => $tileRepresentation) {
// W need to convert indices to positions
// Convert indices to positions
$this->tiles[] = new Tile($rowIndex + 1, $columnIndex + 1, $tileRepresentation);
// Find maximum
// Find longest row
$width = $columnIndex > $width ? $columnIndex : $width;
}
// Find maximum
$height = $rowIndex > $height ? $rowIndex : $height;
}
// Convert indices to dimensions
$this->height = $height + 1;
$this->width = $width + 1;
$this->height = count($this->getDescription());
}
/**
* @return array
*/
public function getDescription() {
return $this->description;
}
/**
@ -70,10 +75,10 @@ class Map {
return $this->tiles;
}
/**
* @param Position $position
* @return Tile|null
* TODO: this might be ambiguous
*/
public function getTileByPosition(Position $position) {
foreach ($this->getTiles() as $tile) {
@ -85,22 +90,10 @@ class Map {
return null;
}
/**
* @return array
*/
public function describedByArray() {
$array = [];
foreach ($this->getTiles() as $tile) {
$array[$tile->getRowIndex()][$tile->getColumnIndex()] = $tile->isRepresentingSpot();
}
return $array;
}
/**
* @param Tile $tile
* @return Tile[]
* TODO: this might be ambiguous
*/
public function getNeighboursOfTile(Tile $tile) {
$neighbouringTiles = [];

@ -12,18 +12,13 @@ namespace Coffee;
*
* @package Coffee
*/
class Table {
class Table extends Map {
/**
* @var Spot[]
*/
private $spots = [];
/**
* @var Map
*/
private $map;
/**
* @var Spot
*/
@ -37,11 +32,11 @@ class Table {
/**
* Table constructor.
*
* @param Map $map
* @param $description [][]
*/
public function __construct(Map $map) {
$this->map = $map;
public function __construct($description) {
parent::__construct($description);
$this->recurseMap();
}
@ -70,7 +65,7 @@ class Table {
* @param Position $searchedPosition
* @return int|string
*/
public function getSpotIndexByPosition(Position $searchedPosition) {
public function getSpotNumberByPosition(Position $searchedPosition) {
// Linear search
// TODO: try to find a faster way
foreach ($this->getSpots() as $spotIndex => $spot) {
@ -142,11 +137,11 @@ class Table {
*/
protected function getNextTile($tile = null) {
if (is_null($tile)) {
$tiles = $this->map->getTiles();
$tiles = $this->getTiles();
return $tiles;
}
else {
$tiles = $this->map->getNeighboursOfTile($tile);
$tiles = $this->getNeighboursOfTile($tile);
return $tiles;
}
}

@ -15,17 +15,6 @@ class MapTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals([$tileA, $tileB], $map->getTiles());
}
public function testDescribedByArray() {
$description = [
[1, 0],
[0, 1],
];
$map = new Map($description);
$this->assertEquals($description, $map->describedByArray());
}
public function testTileByPosition() {
$description = [
[1, 0],

@ -9,31 +9,31 @@ class TableTest extends \PHPUnit_Framework_TestCase {
public function testZeroSpotsCount() {
$map = new Map([
$description = [
[0, 0],
[0, 0],
]);
];
$table = new Table($map);
$table = new Table($description);
$this->assertEquals(0, $table->getSpotsCount());
}
public function testTwoSingleSpotsCount() {
$map = new Map([
$description = [
[0, 1, 0],
[0, 0, 1],
[1, 0, 0],
[0, 1, 0],
]);
];
$table = new Table($map);
$table = new Table($description);
$this->assertEquals(2, $table->getSpotsCount());
}
public function testMultipleLargeSpotsCount() {
$map = new Map([
$description = [
[0, 1, 1, 0, 0],
[0, 0, 1, 0, 1],
[0, 1, 0, 0, 1],
@ -41,22 +41,22 @@ class TableTest extends \PHPUnit_Framework_TestCase {
[1, 0, 0, 1, 1],
[0, 0, 0, 0, 1],
[0, 1, 0, 0, 0],
]);
];
$table = new Table($map);
$table = new Table($description);
$this->assertEquals(4, $table->getSpotsCount());
}
public function testOneSmallSpot() {
$map = new Map([
$description = [
[0, 1, 1],
[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
]);
];
$table = new Table($map);
$table = new Table($description);
$spot = new Spot(new Position(1, 2));
$spot->addPosition(new Position(1, 3));
@ -64,14 +64,14 @@ class TableTest extends \PHPUnit_Framework_TestCase {
}
public function testOneLargeSpot() {
$map = new Map([
$description = [
[0, 1, 1],
[0, 0, 1],
[0, 1, 0],
[1, 0, 0],
]);
];
$table = new Table($map);
$table = new Table($description);
$spot = new Spot(new Position(1, 2));
$spot->addPosition(new Position(1, 3));
$spot->addPosition(new Position(2, 3));
@ -82,14 +82,14 @@ class TableTest extends \PHPUnit_Framework_TestCase {
}
public function testMultipleLargeSpots() {
$map = new Map([
$description = [
[0, 1, 1, 0, 0],
[0, 0, 1, 0, 1],
[0, 1, 0, 0, 1],
[1, 0, 0, 1, 0],
]);
];
$table = new Table($map);
$table = new Table($description);
$spotA = new Spot(new Position(1, 2));
$spotA->addPosition(new Position(1, 3));
@ -105,29 +105,29 @@ class TableTest extends \PHPUnit_Framework_TestCase {
}
public function testLargestSpotSize() {
$map = new Map([
$description = [
[0, 1, 1, 0, 0],
[1, 1, 1, 0, 1],
[0, 0, 1, 0, 1],
[1, 0, 0, 0, 0],
]);
];
$table = new Table($map);
$table = new Table($description);
$this->assertEquals(6, $table->getLargestSpot()->getSize());
}
public function testSpotIndexByPosition() {
$map = new Map([
public function testSpotNumberByPosition() {
$description = [
[0, 1, 1, 0, 0],
[1, 1, 1, 0, 1],
[0, 0, 1, 0, 1],
[1, 0, 0, 0, 0],
]);
];
$table = new Table($map);
$table = new Table($description);
$position = new Position(4, 1);
$this->assertEquals(2, $table->getSpotIndexByPosition($position));
$this->assertEquals(2, $table->getSpotNumberByPosition($position));
}
}

Loading…
Cancel
Save