Rename Tile to Position

master
Peter Babič 8 years ago
parent eb8144ab09
commit 90009f29b4
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 222
      .idea/workspace.xml
  2. 4
      index.php
  3. 31
      src/Coffee/Map.php
  4. 140
      src/Coffee/Position.php
  5. 50
      src/Coffee/Spot.php
  6. 34
      src/Coffee/Table.php
  7. 140
      src/Coffee/Tile.php
  8. 19
      tests/MapTest.php
  9. 110
      tests/PositionTest.php
  10. 12
      tests/SpotTest.php
  11. 10
      tests/TableTest.php
  12. 110
      tests/TileTest.php

@ -1,12 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Implement Map.isValidPosition"> <list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Implement Map.isVisitedPosition">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/codeStyleSettings.xml" afterPath="$PROJECT_DIR$/.idea/codeStyleSettings.xml" /> <change type="MOVED" beforePath="$PROJECT_DIR$/src/Coffee/Tile.php" afterPath="$PROJECT_DIR$/src/Coffee/Position.php" />
<change type="MOVED" beforePath="$PROJECT_DIR$/tests/TileTest.php" afterPath="$PROJECT_DIR$/tests/PositionTest.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/index.php" afterPath="$PROJECT_DIR$/index.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Coffee/Map.php" afterPath="$PROJECT_DIR$/src/Coffee/Map.php" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Coffee/Map.php" afterPath="$PROJECT_DIR$/src/Coffee/Map.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Coffee/Spot.php" afterPath="$PROJECT_DIR$/src/Coffee/Spot.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/MapTest.php" afterPath="$PROJECT_DIR$/tests/MapTest.php" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/MapTest.php" afterPath="$PROJECT_DIR$/tests/MapTest.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/TileTest.php" afterPath="$PROJECT_DIR$/tests/TileTest.php" /> <change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/SpotTest.php" afterPath="$PROJECT_DIR$/tests/SpotTest.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/TableTest.php" afterPath="$PROJECT_DIR$/tests/TableTest.php" />
</list> </list>
<ignored path="coffeetable.iws" /> <ignored path="coffeetable.iws" />
<ignored path=".idea/workspace.xml" /> <ignored path=".idea/workspace.xml" />
@ -32,11 +37,21 @@
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf> <leaf>
<file leaf-file-name="index.php" pinned="false" current-in-tab="true"> <file leaf-file-name="SpotTest.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/tests/SpotTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.13872832">
<caret line="4" column="29" selection-start-line="4" selection-start-column="29" selection-end-line="4" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="index.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/index.php"> <entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.10404624"> <state vertical-scroll-proportion="-14.666667">
<caret line="6" column="5" selection-start-line="6" selection-start-column="5" selection-end-line="6" selection-end-column="5" /> <caret line="22" column="13" selection-start-line="22" selection-start-column="13" selection-end-line="22" selection-end-column="13" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -45,8 +60,8 @@
<file leaf-file-name="Table.php" pinned="false" current-in-tab="false"> <file leaf-file-name="Table.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.6666667"> <state vertical-scroll-proportion="-11.333333">
<caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" /> <caret line="17" column="0" selection-start-line="17" selection-start-column="2" selection-end-line="33" selection-end-column="5" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -55,28 +70,28 @@
<file leaf-file-name="TableTest.php" pinned="false" current-in-tab="false"> <file leaf-file-name="TableTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/TableTest.php"> <entry file="file://$PROJECT_DIR$/tests/TableTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-6.6666665"> <state vertical-scroll-proportion="-2.6666667">
<caret line="10" column="0" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" /> <caret line="4" column="29" selection-start-line="4" selection-start-column="29" selection-end-line="4" selection-end-column="29" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="Tile.php" pinned="false" current-in-tab="false"> <file leaf-file-name="Position.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-79.14815"> <state vertical-scroll-proportion="2.6666667">
<caret line="124" column="55" selection-start-line="124" selection-start-column="55" selection-end-line="124" selection-end-column="55" /> <caret line="5" column="17" selection-start-line="5" selection-start-column="17" selection-end-line="5" selection-end-column="17" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="TileTest.php" pinned="false" current-in-tab="false"> <file leaf-file-name="PositionTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/TileTest.php"> <entry file="file://$PROJECT_DIR$/tests/PositionTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="42.962963"> <state vertical-scroll-proportion="-2.6666667">
<caret line="9" column="0" selection-start-line="9" selection-start-column="0" selection-end-line="9" selection-end-column="0" /> <caret line="4" column="29" selection-start-line="4" selection-start-column="29" selection-end-line="4" selection-end-column="29" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -85,8 +100,8 @@
<file leaf-file-name="Map.php" pinned="false" current-in-tab="false"> <file leaf-file-name="Map.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-45.48148"> <state vertical-scroll-proportion="-43.333332">
<caret line="141" column="25" selection-start-line="141" selection-start-column="25" selection-end-line="141" selection-end-column="25" /> <caret line="70" column="47" selection-start-line="70" selection-start-column="34" selection-end-line="70" selection-end-column="47" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -95,8 +110,8 @@
<file leaf-file-name="MapTest.php" pinned="false" current-in-tab="false"> <file leaf-file-name="MapTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/MapTest.php"> <entry file="file://$PROJECT_DIR$/tests/MapTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-10.407408"> <state vertical-scroll-proportion="-2.6666667">
<caret line="88" column="10" selection-start-line="88" selection-start-column="10" selection-end-line="88" selection-end-column="10" /> <caret line="4" column="29" selection-start-line="4" selection-start-column="29" selection-end-line="4" selection-end-column="29" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -105,18 +120,8 @@
<file leaf-file-name="Spot.php" pinned="false" current-in-tab="false"> <file leaf-file-name="Spot.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-3.8148148"> <state vertical-scroll-proportion="-6.5555553">
<caret line="26" column="0" selection-start-line="26" selection-start-column="0" selection-end-line="26" selection-end-column="0" /> <caret line="27" column="0" selection-start-line="27" selection-start-column="2" selection-end-line="42" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="SpotTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/SpotTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-2.0">
<caret line="3" column="0" selection-start-line="3" selection-start-column="0" selection-end-line="3" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -154,15 +159,17 @@
<option value="$PROJECT_DIR$/.gitignore" /> <option value="$PROJECT_DIR$/.gitignore" />
<option value="/usr/share/nginx/html/coffeetable/tests/TableTest.php" /> <option value="/usr/share/nginx/html/coffeetable/tests/TableTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Tile.php" /> <option value="$PROJECT_DIR$/src/Coffee/Tile.php" />
<option value="$PROJECT_DIR$/src/Coffee/Spot.php" />
<option value="$PROJECT_DIR$/tests/SpotTest.php" />
<option value="$PROJECT_DIR$/index.php" /> <option value="$PROJECT_DIR$/index.php" />
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Table.php" /> <option value="/usr/share/nginx/html/coffeetable/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/tests/TableTest.php" />
<option value="$PROJECT_DIR$/tests/TileTest.php" /> <option value="$PROJECT_DIR$/tests/TileTest.php" />
<option value="$PROJECT_DIR$/tests/MapTest.php" /> <option value="$PROJECT_DIR$/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/src/Coffee/Spot.php" />
<option value="$PROJECT_DIR$/src/Coffee/Map.php" /> <option value="$PROJECT_DIR$/src/Coffee/Map.php" />
<option value="$PROJECT_DIR$/src/Coffee/Position.php" />
<option value="$PROJECT_DIR$/tests/PositionTest.php" />
<option value="$PROJECT_DIR$/tests/MapTest.php" />
<option value="$PROJECT_DIR$/tests/TableTest.php" />
<option value="$PROJECT_DIR$/tests/SpotTest.php" />
</list> </list>
</option> </option>
</component> </component>
@ -404,7 +411,7 @@
<property name="SearchEverywhereHistoryKey" value="rearr&#9;ACTION&#9;RearrangeCode&#10;rea&#9;ACTION&#9;RearrangeCode&#10;orde&#9;null&#9;null&#10;next hi&#9;ACTION&#9;GotoNextError&#10;next&#9;ACTION&#9;GotoNextError&#10;comm cha&#9;ACTION&#9;ChangesView.Commit&#10;comple&#9;ACTION&#9;CodeCompletionGroup&#10;complet&#9;ACTION&#9;CodeCompletionGroup&#10;sear&#9;ACTION&#9;SearchEverywhere&#10;breakpoint&#9;ACTION&#9;ToggleLineBreakpoint&#10;comm ch&#9;ACTION&#9;ChangesView.Commit&#10;smart&#9;ACTION&#9;SmartTypeCompletion&#10;para&#9;ACTION&#9;IntroduceParameter&#10;keyma&#9;ACTION&#9;ChangeKeymap&#10;commit&#9;ACTION&#9;Vcs.CheckCommitMessageSpelling&#10;commit &#9;ACTION&#9;Vcs.CheckCommitMessageSpelling&#10;phpunit&#9;null&#9;null&#10;exte&#9;ACTION&#9;EditorSelectWord&#10;composer&#9;ACTION&#9;ComposerGroup&#10;test&#9;ACTION&#9;RerunTests&#10;rer&#9;ACTION&#9;RerunTests&#10;tests&#9;ACTION&#9;RerunTests&#10;hpunit&#9;ACTION&#9;PhpUnitGenerateTestMethod&#10;phpuni&#9;ACTION&#9;PhpUnitNewTest&#10;rear&#9;ACTION&#9;RearrangeCode" /> <property name="SearchEverywhereHistoryKey" value="rearr&#9;ACTION&#9;RearrangeCode&#10;rea&#9;ACTION&#9;RearrangeCode&#10;orde&#9;null&#9;null&#10;next hi&#9;ACTION&#9;GotoNextError&#10;next&#9;ACTION&#9;GotoNextError&#10;comm cha&#9;ACTION&#9;ChangesView.Commit&#10;comple&#9;ACTION&#9;CodeCompletionGroup&#10;complet&#9;ACTION&#9;CodeCompletionGroup&#10;sear&#9;ACTION&#9;SearchEverywhere&#10;breakpoint&#9;ACTION&#9;ToggleLineBreakpoint&#10;comm ch&#9;ACTION&#9;ChangesView.Commit&#10;smart&#9;ACTION&#9;SmartTypeCompletion&#10;para&#9;ACTION&#9;IntroduceParameter&#10;keyma&#9;ACTION&#9;ChangeKeymap&#10;commit&#9;ACTION&#9;Vcs.CheckCommitMessageSpelling&#10;commit &#9;ACTION&#9;Vcs.CheckCommitMessageSpelling&#10;phpunit&#9;null&#9;null&#10;exte&#9;ACTION&#9;EditorSelectWord&#10;composer&#9;ACTION&#9;ComposerGroup&#10;test&#9;ACTION&#9;RerunTests&#10;rer&#9;ACTION&#9;RerunTests&#10;tests&#9;ACTION&#9;RerunTests&#10;hpunit&#9;ACTION&#9;PhpUnitGenerateTestMethod&#10;phpuni&#9;ACTION&#9;PhpUnitNewTest&#10;rear&#9;ACTION&#9;RearrangeCode" />
<property name="settings.editor.selected.configurable" value="preferences.sourceCode.PHP" /> <property name="settings.editor.selected.configurable" value="preferences.sourceCode.PHP" />
<property name="settings.editor.splitter.proportion" value="0.2" /> <property name="settings.editor.splitter.proportion" value="0.2" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="last_opened_file_path" value="$PROJECT_DIR$/tests" />
<property name="last_directory_selection" value="$PROJECT_DIR$" /> <property name="last_directory_selection" value="$PROJECT_DIR$" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth0" value="104" /> <property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth0" value="104" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder0" value="0" /> <property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder0" value="0" />
@ -430,14 +437,14 @@
</key> </key>
</component> </component>
<component name="RunManager" selected="PHPUnit.Tests"> <component name="RunManager" selected="PHPUnit.Tests">
<configuration default="false" name="TileTest.php" type="PhpLocalRunConfigurationType" factoryName="PHP Console" temporary="true" path="$PROJECT_DIR$/tests/TileTest.php"> <configuration default="false" name="PositionTest.php" type="PhpLocalRunConfigurationType" factoryName="PHP Console" temporary="true" path="$PROJECT_DIR$/tests/PositionTest.php">
<method /> <method />
</configuration> </configuration>
<configuration default="false" name="TableTest" type="PHPUnitRunConfigurationType" factoryName="PHPUnit" temporary="true"> <configuration default="false" name="TableTest" type="PHPUnitRunConfigurationType" factoryName="PHPUnit" temporary="true">
<TestRunner class="Coffee\TableTest" configuration_file="$PROJECT_DIR$/phpunit.xml" directory="$PROJECT_DIR$/tests" file="$PROJECT_DIR$/tests/TableTest.php" scope="Class" options="--bootstrap vendor/autoload.php" use_alternative_configuration_file="true" /> <TestRunner class="Coffee\TableTest" configuration_file="$PROJECT_DIR$/phpunit.xml" directory="$PROJECT_DIR$/tests" file="$PROJECT_DIR$/tests/TableTest.php" scope="Class" options="--bootstrap vendor/autoload.php" use_alternative_configuration_file="true" />
<method /> <method />
</configuration> </configuration>
<configuration default="false" name="TileTest.php" type="JavascriptDebugType" factoryName="JavaScript Debug" temporary="true" nameIsGenerated="true" uri="http://localhost:63342/coffeetable/tests/TileTest.php"> <configuration default="false" name="PositionTest.php" type="JavascriptDebugType" factoryName="JavaScript Debug" temporary="true" nameIsGenerated="true" uri="http://localhost:63342/coffeetable/tests/PositionTest.php">
<method /> <method />
</configuration> </configuration>
<configuration default="false" name="index.php" type="PhpLocalRunConfigurationType" factoryName="PHP Console" temporary="true" path="$PROJECT_DIR$/index.php"> <configuration default="false" name="index.php" type="PhpLocalRunConfigurationType" factoryName="PHP Console" temporary="true" path="$PROJECT_DIR$/index.php">
@ -480,17 +487,17 @@
</configuration> </configuration>
<list size="5"> <list size="5">
<item index="0" class="java.lang.String" itemvalue="PHPUnit.Tests" /> <item index="0" class="java.lang.String" itemvalue="PHPUnit.Tests" />
<item index="1" class="java.lang.String" itemvalue="PHP Script.TileTest.php" /> <item index="1" class="java.lang.String" itemvalue="PHP Script.PositionTest.php" />
<item index="2" class="java.lang.String" itemvalue="PHPUnit.TableTest" /> <item index="2" class="java.lang.String" itemvalue="PHPUnit.TableTest" />
<item index="3" class="java.lang.String" itemvalue="JavaScript Debug.TileTest.php" /> <item index="3" class="java.lang.String" itemvalue="JavaScript Debug.PositionTest.php" />
<item index="4" class="java.lang.String" itemvalue="PHP Script.index.php" /> <item index="4" class="java.lang.String" itemvalue="PHP Script.index.php" />
</list> </list>
<recent_temporary> <recent_temporary>
<list size="4"> <list size="4">
<item index="0" class="java.lang.String" itemvalue="PHP Script.index.php" /> <item index="0" class="java.lang.String" itemvalue="PHP Script.index.php" />
<item index="1" class="java.lang.String" itemvalue="JavaScript Debug.TileTest.php" /> <item index="1" class="java.lang.String" itemvalue="JavaScript Debug.PositionTest.php" />
<item index="2" class="java.lang.String" itemvalue="PHPUnit.TableTest" /> <item index="2" class="java.lang.String" itemvalue="PHPUnit.TableTest" />
<item index="3" class="java.lang.String" itemvalue="PHP Script.TileTest.php" /> <item index="3" class="java.lang.String" itemvalue="PHP Script.PositionTest.php" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
@ -565,38 +572,44 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1458207812223</updated> <updated>1458207812223</updated>
</task> </task>
<option name="localTasksCounter" value="11" /> <task id="LOCAL-00011" summary="Implement Map.isVisitedPosition">
<created>1458209330980</created>
<option name="number" value="00011" />
<option name="project" value="LOCAL" />
<updated>1458209330980</updated>
</task>
<option name="localTasksCounter" value="12" />
<servers /> <servers />
</component> </component>
<component name="TestHistory"> <component name="TestHistory">
<history-entry file="Tests - 2016.03.17 at 10h 42m 45s.xml"> <history-entry file="Tests - 2016.03.17 at 11h 03m 46s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 10h 43m 07s.xml"> <history-entry file="Tests - 2016.03.17 at 11h 15m 04s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 10h 43m 18s.xml"> <history-entry file="Tests - 2016.03.17 at 11h 16m 54s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 10h 46m 07s.xml"> <history-entry file="Tests - 2016.03.17 at 11h 17m 07s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 10h 46m 14s.xml"> <history-entry file="Tests - 2016.03.17 at 11h 17m 35s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 10h 48m 35s.xml"> <history-entry file="Tests - 2016.03.17 at 12h 39m 01s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 11h 00m 06s.xml"> <history-entry file="Tests - 2016.03.17 at 12h 41m 01s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 11h 01m 32s.xml"> <history-entry file="Tests - 2016.03.17 at 12h 49m 52s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 11h 02m 07s.xml"> <history-entry file="Tests - 2016.03.17 at 12h 52m 32s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
<history-entry file="Tests - 2016.03.17 at 11h 03m 46s.xml"> <history-entry file="Tests - 2016.03.17 at 12h 58m 55s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" /> <configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry> </history-entry>
</component> </component>
@ -610,7 +623,7 @@
<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="7" 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="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.28553617" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.28553617" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" 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="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" 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="7" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.19375" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.16875" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" /> <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<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="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="false" 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" />
@ -670,7 +683,8 @@
<MESSAGE value="Refactor Tile constructor to accept parameters&#10;" /> <MESSAGE value="Refactor Tile constructor to accept parameters&#10;" />
<MESSAGE value="Refactor Table constructor to accept arguments" /> <MESSAGE value="Refactor Table constructor to accept arguments" />
<MESSAGE value="Implement Map.isValidPosition" /> <MESSAGE value="Implement Map.isValidPosition" />
<option name="LAST_COMMIT_MESSAGE" value="Implement Map.isValidPosition" /> <MESSAGE value="Implement Map.isVisitedPosition" />
<option name="LAST_COMMIT_MESSAGE" value="Implement Map.isVisitedPosition" />
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" /> <option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="true" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
@ -684,22 +698,6 @@
</watches-manager> </watches-manager>
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/SpotTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="17" column="35" selection-start-line="17" selection-start-column="35" selection-end-line="17" selection-end-column="35" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
@ -723,7 +721,7 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="55" column="42" selection-start-line="55" selection-start-column="42" selection-end-line="55" selection-end-column="42" /> <caret line="55" column="42" selection-start-line="55" selection-start-column="42" selection-end-line="55" selection-end-column="42" />
@ -731,7 +729,7 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/tests/TileTest.php"> <entry file="file://$PROJECT_DIR$/tests/PositionTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" /> <caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" />
@ -762,7 +760,7 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="55" column="42" selection-start-line="55" selection-start-column="42" selection-end-line="55" selection-end-column="42" /> <caret line="55" column="42" selection-start-line="55" selection-start-column="42" selection-end-line="55" selection-end-column="42" />
@ -770,7 +768,7 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/tests/TileTest.php"> <entry file="file://$PROJECT_DIR$/tests/PositionTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" /> <caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" />
@ -801,7 +799,7 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="55" column="42" selection-start-line="55" selection-start-column="42" selection-end-line="55" selection-end-column="42" /> <caret line="55" column="42" selection-start-line="55" selection-start-column="42" selection-end-line="55" selection-end-column="42" />
@ -809,7 +807,7 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/tests/TileTest.php"> <entry file="file://$PROJECT_DIR$/tests/PositionTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" /> <caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" />
@ -840,7 +838,7 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="55" column="42" selection-start-line="55" selection-start-column="42" selection-end-line="55" selection-end-column="42" /> <caret line="55" column="42" selection-start-line="55" selection-start-column="42" selection-end-line="55" selection-end-column="42" />
@ -848,7 +846,7 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/tests/TileTest.php"> <entry file="file://$PROJECT_DIR$/tests/PositionTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" /> <caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" />
@ -872,7 +870,7 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="113" column="62" selection-start-line="113" selection-start-column="62" selection-end-line="113" selection-end-column="62" /> <caret line="113" column="62" selection-start-line="113" selection-start-column="62" selection-end-line="113" selection-end-column="62" />
@ -887,7 +885,7 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/tests/TileTest.php"> <entry file="file://$PROJECT_DIR$/tests/PositionTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0"> <state vertical-scroll-proportion="0.0">
<caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" /> <caret line="80" column="35" selection-start-line="80" selection-start-column="35" selection-end-line="80" selection-end-column="35" />
@ -1001,74 +999,74 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/tests/SpotTest.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-2.0"> <state vertical-scroll-proportion="-6.5555553">
<caret line="3" column="0" selection-start-line="3" selection-start-column="0" selection-end-line="3" selection-end-column="0" /> <caret line="27" column="0" selection-start-line="27" selection-start-column="2" selection-end-line="42" selection-end-column="5" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/tests/TableTest.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-6.6666665"> <state vertical-scroll-proportion="-11.333333">
<caret line="10" column="0" selection-start-line="10" selection-start-column="0" selection-end-line="10" selection-end-column="0" /> <caret line="17" column="0" selection-start-line="17" selection-start-column="2" selection-end-line="33" selection-end-column="5" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php"> <entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-3.8148148"> <state vertical-scroll-proportion="-14.666667">
<caret line="26" column="0" selection-start-line="26" selection-start-column="0" selection-end-line="26" selection-end-column="0" /> <caret line="22" column="13" selection-start-line="22" selection-start-column="13" selection-end-line="22" selection-end-column="13" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-79.14815"> <state vertical-scroll-proportion="-43.333332">
<caret line="124" column="55" selection-start-line="124" selection-start-column="55" selection-end-line="124" selection-end-column="55" /> <caret line="70" column="47" selection-start-line="70" selection-start-column="34" selection-end-line="70" selection-end-column="47" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php"> <entry file="file://$PROJECT_DIR$/tests/MapTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-0.6666667"> <state vertical-scroll-proportion="-2.6666667">
<caret line="1" column="0" selection-start-line="1" selection-start-column="0" selection-end-line="1" selection-end-column="0" /> <caret line="4" column="29" selection-start-line="4" selection-start-column="29" selection-end-line="4" selection-end-column="29" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/tests/TileTest.php"> <entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="42.962963"> <state vertical-scroll-proportion="2.6666667">
<caret line="9" column="0" selection-start-line="9" selection-start-column="0" selection-end-line="9" selection-end-column="0" /> <caret line="5" column="17" selection-start-line="5" selection-start-column="17" selection-end-line="5" selection-end-column="17" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/tests/MapTest.php"> <entry file="file://$PROJECT_DIR$/tests/PositionTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-10.407408"> <state vertical-scroll-proportion="-2.6666667">
<caret line="88" column="10" selection-start-line="88" selection-start-column="10" selection-end-line="88" selection-end-column="10" /> <caret line="4" column="29" selection-start-line="4" selection-start-column="29" selection-end-line="4" selection-end-column="29" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php"> <entry file="file://$PROJECT_DIR$/tests/TableTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-45.48148"> <state vertical-scroll-proportion="-2.6666667">
<caret line="141" column="25" selection-start-line="141" selection-start-column="25" selection-end-line="141" selection-end-column="25" /> <caret line="4" column="29" selection-start-line="4" selection-start-column="29" selection-end-line="4" selection-end-column="29" />
<folding /> <folding />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/index.php"> <entry file="file://$PROJECT_DIR$/tests/SpotTest.php">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.10404624"> <state vertical-scroll-proportion="0.13872832">
<caret line="6" column="5" selection-start-line="6" selection-start-column="5" selection-end-line="6" selection-end-column="5" /> <caret line="4" column="29" selection-start-line="4" selection-start-column="29" selection-end-line="4" selection-end-column="29" />
<folding /> <folding />
</state> </state>
</provider> </provider>

@ -17,8 +17,8 @@ try {
foreach ($map->describedByArray() as $mapRowIndex => $mapRow) { foreach ($map->describedByArray() as $mapRowIndex => $mapRow) {
foreach ($mapRow as $mapColumnIndex => $containsCoffee) { foreach ($mapRow as $mapColumnIndex => $containsCoffee) {
if ($containsCoffee == true) { if ($containsCoffee == true) {
$tile = new Tile($mapColumnIndex, $mapRowIndex); $position = new Position($mapColumnIndex, $mapRowIndex);
$spot = new Spot($tile); $spot = new Spot($position);
$table->addSpot($spot); $table->addSpot($spot);
} }
} }

@ -43,7 +43,7 @@ class Map {
* @throws Exception * @throws Exception
*/ */
public function __construct($description) { public function __construct($description) {
if (is_null($description) || !is_array($description)) { if (is_null($description) || !is_array($description) || !is_array($description[0])) {
throw new Exception('The Coffee Table map could not be loaded.'); throw new Exception('The Coffee Table map could not be loaded.');
} }
@ -60,6 +60,9 @@ class Map {
return $this->description; return $this->description;
} }
// public function getNextUnvisitedPosition() {
// forek
//}
/** /**
* @param $row * @param $row
* @param $column * @param $column
@ -106,6 +109,19 @@ class Map {
return $this->width; return $this->width;
} }
/**
* @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);
}
/** /**
* @param $description * @param $description
* @return int * @return int
@ -132,17 +148,4 @@ class Map {
return count($description); 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);
}
} }

@ -0,0 +1,140 @@
<?php
namespace Coffee;
/**
* Class Position
*
* @package Coffee
*/
class Position {
/**
* @var int
*/
private $column = 0;
/**
* @var int
*/
private $row = 0;
/**
* @param $row
* @param $column
*/
function __construct($row, $column) {
$this->column = $column;
$this->row = $row;
}
/**
* @return int
*/
public function getColumn() {
return $this->column;
}
/**
* @return int
*/
public function getRow() {
return $this->row;
}
/**
* @param Position $position
* @return bool
*/
public function isTheSameColumn(Position $position) {
return $this->getColumn() == $position->getColumn();
}
/**
* @param Position $position
* @return bool
*/
public function isTheSameRow(Position $position) {
return $this->getRow() == $position->getRow();
}
/**
* @param Position $position
* @return bool
*/
public function isTheSamePosition(Position $position) {
return $this->isTheSameColumn($position) && $this->isTheSameRow($position);
}
/**
* @return Position
*/
public function getNorthEastPosition() {
return new Position($this->getRow() - 1, $this->getColumn() + 1);
}
/**
* @return Position
*/
public function getEastPosition() {
return new Position($this->getRow(), $this->getColumn() + 1);
}
/**
* @return Position
*/
public function getSouthEastPosition() {
return new Position($this->getRow() + 1, $this->getColumn() + 1);
}
/**
* @return Position
*/
public function getSouthPosition() {
return new Position($this->getRow() + 1, $this->getColumn());
}
/**
* @return Position
*/
public function getSouthWestPosition() {
return new Position($this->getRow() + 1, $this->getColumn() - 1);
}
/**
* @return Position
*/
public function getWestPosition() {
return new Position($this->getRow(), $this->getColumn() - 1);
}
/**
* @return Position
*/
public function getNorthWestPosition() {
return new Position($this->getRow() - 1, $this->getColumn() - 1);
}
/**
* @return Position
*/
public function getNorthPosition() {
return new Position($this->getRow() - 1, $this->getColumn());
}
/**
* @return array Neighbors of position from NE to N; CW direction
*/
public function getNeighbors() {
return [
$this->getNorthEastPosition(),
$this->getEastPosition(),
$this->getSouthEastPosition(),
$this->getSouthPosition(),
$this->getSouthWestPosition(),
$this->getWestPosition(),
$this->getNorthWestPosition(),
$this->getNorthPosition(),
];
}
}

@ -21,45 +21,45 @@ namespace Coffee;
class Spot { class Spot {
/** /**
* @var Tile[] * @var Position[]
*/ */
private $tiles = []; private $positions = [];
/** // /**
* Spot constructor. // * Spot constructor.
* // *
* @param Tile|Tile[] $tiles // * @param Position|Position[] $positions
*/ // */
public function __construct($tiles = null) { // public function __construct($positions = null) {
if ($tiles instanceof Tile) { // if ($positions instanceof Position) {
$this->addTile($tiles); // $this->addPosition($positions);
} // }
//
if (is_array($tiles)) { // if (is_array($positions)) {
foreach ($tiles as $tile) { // foreach ($positions as $position) {
$this->addTile($tile); // $this->addPosition($position);
} // }
} // }
} // }
/** /**
* @param Tile $tile * @param Position $position
* @return bool * @return bool
*/ */
public function addTile(Tile $tile) { public function addPosition(Position $position) {
if (is_null($tile)) { if (is_null($position)) {
return false; return false;
} }
$this->tiles[] = $tile; $this->positions[] = $position;
return true; return true;
} }
/** /**
* @return Tile[] * @return Position[]
*/ */
public function getTiles() { public function getPositions() {
return $this->tiles; return $this->positions;
} }
} }

@ -15,23 +15,23 @@ class Table {
*/ */
private $spots = []; private $spots = [];
/** // /**
* Table constructor. // * Table constructor.
* // *
* @param Spot|Spot[] $spots // * @param Spot|Spot[] $spots
*/ // */
public function __construct($spots = null) { // public function __construct($spots = null) {
if ($spots instanceof Spot) { // if ($spots instanceof Spot) {
$this->addSpot($spots); // $this->addSpot($spots);
} // }
//
if (is_array($spots)) { // if (is_array($spots)) {
foreach ($spots as $spot) { // foreach ($spots as $spot) {
$this->addSpot($spot); // $this->addSpot($spot);
} // }
} // }
//
} // }
/** /**
* @param Spot $spot * @param Spot $spot

@ -1,140 +0,0 @@
<?php
namespace Coffee;
/**
* Class Tile
*
* @package Coffee
*/
class Tile {
/**
* @var int
*/
private $column = 0;
/**
* @var int
*/
private $row = 0;
/**
* @param $row
* @param $column
*/
function __construct($row, $column) {
$this->column = $column;
$this->row = $row;
}
/**
* @return int
*/
public function getColumn() {
return $this->column;
}
/**
* @return int
*/
public function getRow() {
return $this->row;
}
/**
* @param Tile $tile
* @return bool
*/
public function isTheSameColumn(Tile $tile) {
return $this->getColumn() == $tile->getColumn();
}
/**
* @param Tile $tile
* @return bool
*/
public function isTheSameRow(Tile $tile) {
return $this->getRow() == $tile->getRow();
}
/**
* @param Tile $tile
* @return bool
*/
public function isTheSameTile(Tile $tile) {
return $this->isTheSameColumn($tile) && $this->isTheSameRow($tile);
}
/**
* @return Tile
*/
public function getNorthEastTile() {
return new Tile($this->getRow() - 1, $this->getColumn() + 1);
}
/**
* @return Tile
*/
public function getEastTile() {
return new Tile($this->getRow(), $this->getColumn() + 1);
}
/**
* @return Tile
*/
public function getSouthEastTile() {
return new Tile($this->getRow() + 1, $this->getColumn() + 1);
}
/**
* @return Tile
*/
public function getSouthTile() {
return new Tile($this->getRow() + 1, $this->getColumn());
}
/**
* @return Tile
*/
public function getSouthWestTile() {
return new Tile($this->getRow() + 1, $this->getColumn() - 1);
}
/**
* @return Tile
*/
public function getWestTile() {
return new Tile($this->getRow(), $this->getColumn() - 1);
}
/**
* @return Tile
*/
public function getNorthWestTile() {
return new Tile($this->getRow() - 1, $this->getColumn() - 1);
}
/**
* @return Tile
*/
public function getNorthTile() {
return new Tile($this->getRow() - 1, $this->getColumn());
}
/**
* @return array Neighbors of tile from NE to N; CW direction
*/
public function getNeighbors() {
return [
$this->getNorthEastTile(),
$this->getEastTile(),
$this->getSouthEastTile(),
$this->getSouthTile(),
$this->getSouthWestTile(),
$this->getWestTile(),
$this->getNorthWestTile(),
$this->getNorthTile(),
];
}
}

@ -2,7 +2,7 @@
namespace Coffee; namespace Coffee;
// This is not necessary, sice it is bootstrapped but serves for debugging purposes // This is not necessary, since it is bootstrapped but serves for debugging purposes
require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/autoload.php';
class MapTest extends \PHPUnit_Framework_TestCase { class MapTest extends \PHPUnit_Framework_TestCase {
@ -79,7 +79,7 @@ class MapTest extends \PHPUnit_Framework_TestCase {
$this->assertTrue($map->isVisitedPosition(0, 0)); $this->assertTrue($map->isVisitedPosition(0, 0));
} }
public function testNotVisitedPosition() { public function testUnvisitedPosition() {
$description = [ $description = [
[0, 1, 0, 1], [0, 1, 0, 1],
[1, 0, 0, 0], [1, 0, 0, 0],
@ -92,4 +92,19 @@ class MapTest extends \PHPUnit_Framework_TestCase {
$this->assertFalse($map->isVisitedPosition(4, 0)); $this->assertFalse($map->isVisitedPosition(4, 0));
} }
// public function testNextUnvisitedPosition() {
// $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);
// $map->visitPosition(0, 1);
//
// $position = new Position(0, 2);
// $this->assertEquals($position, $map->getNextUnvisitedPosition());
// }
} }

@ -0,0 +1,110 @@
<?php
namespace Coffee;
// This is not necessary, since it is bootstrapped but serves for debugging purposes
require __DIR__ . '/../vendor/autoload.php';
class PositionTest extends \PHPUnit_Framework_TestCase {
public function testTheSameX() {
$positionA = new Position(2, 2);
$positionB = new Position(2, 2);
$this->assertTrue($positionA->isTheSameColumn($positionB));
}
public function testTheSameY() {
$positionA = new Position(2, 2);
$positionB = new Position(2, 2);
$this->assertTrue($positionA->isTheSameRow($positionB));
}
public function testTheSamePosition() {
$positionA = new Position(2, 2);
$positionB = new Position(2, 2);
$this->assertTrue($positionA->isTheSamePosition($positionB));
}
public function testNorthEastPosition() {
$position = new Position(2, 2);
$northEastPositionA = $position->getNorthEastPosition();
$northEastPositionB = new Position(1, 3);
$this->assertTrue($northEastPositionA->isTheSamePosition($northEastPositionB));
}
public function testEastPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getEastPosition();
$NorthPositionB = new Position(2, 3);
$this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
}
public function testSouthEastPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getSouthEastPosition();
$NorthPositionB = new Position(3, 3);
$this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
}
public function testSouthPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getSouthPosition();
$NorthPositionB = new Position(3, 2);
$this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
}
public function testsSouthWestPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getSouthWestPosition();
$NorthPositionB = new Position(3, 1);
$this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
}
public function testWestPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getWestPosition();
$NorthPositionB = new Position(2, 1);
$this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
}
public function testNorthWestPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getNorthWestPosition();
$NorthPositionB = new Position(1, 1);
$this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
}
public function testNorthPosition() {
$position = new Position(2, 2);
$northPositionA = $position->getNorthPosition();
$NorthPositionB = new Position(1, 2);
$this->assertTrue($northPositionA->isTheSamePosition($NorthPositionB));
}
public function testNeighbors() {
$position = new Position(2, 2);
$neighbours = [
new Position(1, 3),
new Position(2, 3),
new Position(3, 3),
new Position(3, 2),
new Position(3, 1),
new Position(2, 1),
new Position(1, 1),
new Position(1, 2),
];
$this->assertEquals($neighbours, $position->getNeighbors());
}
}

@ -2,16 +2,16 @@
namespace Coffee; namespace Coffee;
// This is not necessary, sice it is bootstrapped but serves for debugging purposes // This is not necessary, since it is bootstrapped but serves for debugging purposes
require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/autoload.php';
class SpotTest extends \PHPUnit_Framework_TestCase { class SpotTest extends \PHPUnit_Framework_TestCase {
public function testGetTiles() { public function testGetPositions() {
$tile = new Tile(2, 1); $position = new Position(2, 1);
$spot = new Spot([$tile, $tile]); $spot = new Spot();
// $spot->addTile($tile); $spot->addPosition($position);
$this->assertEquals([$tile, $tile], $spot->getTiles()); $this->assertEquals([$position], $spot->getPositions());
} }
} }

@ -2,27 +2,27 @@
namespace Coffee; namespace Coffee;
// This is not necessary, sice it is bootstrapped but serves for debugging purposes // This is not necessary, since it is bootstrapped but serves for debugging purposes
require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/autoload.php';
class TableTest extends \PHPUnit_Framework_TestCase { class TableTest extends \PHPUnit_Framework_TestCase {
public function testGetSpots() { public function testGetSpots() {
$tile = new Tile(0, 0); $position = new Position(0, 0);
$spot = new Spot(); $spot = new Spot();
$table = new Table(); $table = new Table();
$spot->addTile($tile); $spot->addPosition($position);
$table->addSpot($spot); $table->addSpot($spot);
$this->assertEquals([$spot], $table->getSpots()); $this->assertEquals([$spot], $table->getSpots());
} }
public function testSpotsCount() { public function testSpotsCount() {
$tile = new Tile(0, 0); $position = new Position(0, 0);
$spot = new Spot(); $spot = new Spot();
$table = new Table(); $table = new Table();
$spot->addTile($tile); $spot->addPosition($position);
$table->addSpot($spot); $table->addSpot($spot);
$table->addSpot($spot); $table->addSpot($spot);
$this->assertEquals(2, $table->getSpotsCount()); $this->assertEquals(2, $table->getSpotsCount());

@ -1,110 +0,0 @@
<?php
namespace Coffee;
// This is not necessary, sice it is bootstrapped but serves for debugging purposes
require __DIR__ . '/../vendor/autoload.php';
class TileTest extends \PHPUnit_Framework_TestCase {
public function testTheSameX() {
$tileA = new Tile(2, 2);
$tileB = new Tile(2, 2);
$this->assertTrue($tileA->isTheSameColumn($tileB));
}
public function testTheSameY() {
$tileA = new Tile(2, 2);
$tileB = new Tile(2, 2);
$this->assertTrue($tileA->isTheSameRow($tileB));
}
public function testTheSameTile() {
$tileA = new Tile(2, 2);
$tileB = new Tile(2, 2);
$this->assertTrue($tileA->isTheSameTile($tileB));
}
public function testNorthEastTile() {
$tile = new Tile(2, 2);
$northEastTileA = $tile->getNorthEastTile();
$northEastTileB = new Tile(1, 3);
$this->assertTrue($northEastTileA->isTheSameTile($northEastTileB));
}
public function testEastTile() {
$tile = new Tile(2, 2);
$northTileA = $tile->getEastTile();
$NorthTileB = new Tile(2, 3);
$this->assertTrue($northTileA->isTheSameTile($NorthTileB));
}
public function testSouthEastTile() {
$tile = new Tile(2, 2);
$northTileA = $tile->getSouthEastTile();
$NorthTileB = new Tile(3, 3);
$this->assertTrue($northTileA->isTheSameTile($NorthTileB));
}
public function testSouthTile() {
$tile = new Tile(2, 2);
$northTileA = $tile->getSouthTile();
$NorthTileB = new Tile(3, 2);
$this->assertTrue($northTileA->isTheSameTile($NorthTileB));
}
public function testsSouthWestTile() {
$tile = new Tile(2, 2);
$northTileA = $tile->getSouthWestTile();
$NorthTileB = new Tile(3, 1);
$this->assertTrue($northTileA->isTheSameTile($NorthTileB));
}
public function testWestTile() {
$tile = new Tile(2, 2);
$northTileA = $tile->getWestTile();
$NorthTileB = new Tile(2, 1);
$this->assertTrue($northTileA->isTheSameTile($NorthTileB));
}
public function testNorthWestTile() {
$tile = new Tile(2, 2);
$northTileA = $tile->getNorthWestTile();
$NorthTileB = new Tile(1, 1);
$this->assertTrue($northTileA->isTheSameTile($NorthTileB));
}
public function testNorthTile() {
$tile = new Tile(2, 2);
$northTileA = $tile->getNorthTile();
$NorthTileB = new Tile(1, 2);
$this->assertTrue($northTileA->isTheSameTile($NorthTileB));
}
public function testNeighbors() {
$tile = new Tile(2, 2);
$neighbours = [
new Tile(1, 3),
new Tile(2, 3),
new Tile(3, 3),
new Tile(3, 2),
new Tile(3, 1),
new Tile(2, 1),
new Tile(1, 1),
new Tile(1, 2),
];
$this->assertEquals($neighbours, $tile->getNeighbors());
}
}
Loading…
Cancel
Save