Implement Spot size

master
Peter Babič 8 years ago
parent 72b4370c40
commit 30ef9912b4
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 276
      .idea/workspace.xml
  2. 28
      index.php
  3. 14
      src/Coffee/Spot.php
  4. 48
      src/Coffee/Table.php
  5. 11
      tests/Coffee/SpotTest.php
  6. 27
      tests/Coffee/TableTest.php

@ -4,9 +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 recursive algoritm to find one large spot">
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Implement Spot size">
<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/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/Coffee/SpotTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/SpotTest.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/Coffee/TableTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
</list>
<ignored path="coffeetable.iws" />
@ -36,8 +39,8 @@
<file leaf-file-name="index.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.45721924">
<caret line="19" column="0" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" />
<state vertical-scroll-proportion="0.2603306">
<caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="22" selection-end-column="35" />
<folding />
</state>
</provider>
@ -46,8 +49,8 @@
<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="-57.703705">
<caret line="91" column="5" selection-start-line="91" selection-start-column="5" selection-end-line="91" selection-end-column="5" />
<state vertical-scroll-proportion="-17.0">
<caret line="47" column="7" selection-start-line="47" selection-start-column="7" selection-end-line="47" selection-end-column="7" />
<folding />
</state>
</provider>
@ -56,8 +59,8 @@
<file leaf-file-name="TableTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/TableTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="6.296296">
<caret line="47" column="56" selection-start-line="47" selection-start-column="56" selection-end-line="47" selection-end-column="56" />
<state vertical-scroll-proportion="-11.703704">
<caret line="115" column="0" selection-start-line="115" selection-start-column="0" selection-end-line="115" selection-end-column="0" />
<folding />
</state>
</provider>
@ -66,38 +69,38 @@
<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="-20.0">
<caret line="35" column="19" selection-start-line="35" selection-start-column="19" selection-end-line="35" selection-end-column="19" />
<state vertical-scroll-proportion="0.0">
<caret line="30" column="26" selection-start-line="30" selection-start-column="26" selection-end-line="30" selection-end-column="26" />
<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">
<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="-11.0">
<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="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>
</file>
<file leaf-file-name="Map.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<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="-33.037037">
<caret line="147" column="0" selection-start-line="147" selection-start-column="0" selection-end-line="147" selection-end-column="0" />
<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>
</file>
<file leaf-file-name="MapTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php">
<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="-8.0">
<caret line="12" column="0" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
<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>
@ -106,7 +109,7 @@
<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="-48.0">
<state vertical-scroll-proportion="0.0">
<caret line="72" column="20" selection-start-line="72" selection-start-column="20" selection-end-line="72" selection-end-column="20" />
<folding />
</state>
@ -116,13 +119,23 @@
<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="-0.0">
<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>
</file>
<file leaf-file-name="PositionTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="42" column="29" selection-start-line="42" selection-start-column="29" selection-end-line="42" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FrameworkCommandLineHistory">
@ -136,9 +149,6 @@
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="mock:///Dummy.txt" root0="SKIP_INSPECTION" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
@ -171,11 +181,13 @@
<option value="$PROJECT_DIR$/composer.json" />
<option value="$PROJECT_DIR$/tests/Coffee/PositionTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/MapTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/SpotTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TileTest.php" />
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/Output.php" />
<option value="$PROJECT_DIR$/tests/Coffee/OutputTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Map.php" />
<option value="$PROJECT_DIR$/src/Coffee/Spot.php" />
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/tests/Coffee/SpotTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
<option value="$PROJECT_DIR$/index.php" />
@ -365,21 +377,6 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope">
<subPane subId="Project Files">
<PATH>
<PATH_ELEMENT USER_OBJECT="Root">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
<PATH_ELEMENT USER_OBJECT="coffeetable">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<PATH>
@ -436,6 +433,21 @@
</PATH>
</subPane>
</pane>
<pane id="Scope">
<subPane subId="Project Files">
<PATH>
<PATH_ELEMENT USER_OBJECT="Root">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
<PATH_ELEMENT USER_OBJECT="coffeetable">
<option name="myItemId" value="" />
<option name="myItemType" value="" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
@ -446,7 +458,7 @@
<property name="SearchEverywhereHistoryKey" value="colum&#9;ACTION&#9;EditorToggleColumnMode&#10;reform&#9;ACTION&#9;ReformatCode&#10;replace in pa&#9;ACTION&#9;ReplaceInPath&#10;hist&#9;ACTION&#9;Vcs.ShowTabbedFileHistory&#10;paste&#9;ACTION&#9;EditorPasteSimple&#10;rear &#9;ACTION&#9;RearrangeCode&#10;histor&#9;ACTION&#9;Vcs.ShowTabbedFileHistory&#10;rep in pa&#9;ACTION&#9;ReplaceInPath&#10;replace in&#9;ACTION&#9;ReplaceInPath&#10;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.splitter.proportion" value="0.2" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../coffeetable_branch" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/tests/Coffee" />
<property name="last_directory_selection" value="$PROJECT_DIR$" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth0" value="103" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder0" value="0" />
@ -724,38 +736,44 @@
<option name="project" value="LOCAL" />
<updated>1458304427895</updated>
</task>
<option name="localTasksCounter" value="33" />
<task id="LOCAL-00033" summary="Implement recursive algorithm to find Spots">
<created>1458308469594</created>
<option name="number" value="00033" />
<option name="project" value="LOCAL" />
<updated>1458308469594</updated>
</task>
<option name="localTasksCounter" value="34" />
<servers />
</component>
<component name="TestHistory">
<history-entry file="Tests - 2016.03.18 at 13h 37m 41s.xml">
<history-entry file="Tests - 2016.03.19 at 11h 46m 05s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.18 at 13h 38m 00s.xml">
<history-entry file="Tests - 2016.03.19 at 12h 42m 05s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.18 at 13h 38m 16s.xml">
<history-entry file="Tests - 2016.03.19 at 12h 46m 21s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.18 at 13h 38m 20s.xml">
<history-entry file="Tests - 2016.03.19 at 13h 15m 08s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.18 at 13h 38m 43s.xml">
<history-entry file="Tests - 2016.03.19 at 13h 15m 15s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.18 at 13h 39m 11s.xml">
<history-entry file="Tests - 2016.03.19 at 13h 15m 23s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.18 at 13h 39m 40s.xml">
<history-entry file="Tests - 2016.03.19 at 13h 15m 27s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.18 at 13h 40m 07s.xml">
<history-entry file="Tests - 2016.03.20 at 17h 03m 49s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.18 at 13h 40m 23s.xml">
<history-entry file="Tests - 2016.03.20 at 17h 03m 55s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.18 at 13h 42m 32s.xml">
<history-entry file="Tests - 2016.03.20 at 17h 11m 17s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
</component>
@ -763,25 +781,25 @@
<frame x="-2" y="0" width="1444" height="899" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23333333" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="TODO" 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="6" side_tool="false" content_ui="tabs" />
<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="Messages" 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="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="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3990025" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Command Line Tools Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3316583" sideWeight="0.5" order="11" 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="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="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="10" 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.23333333" sideWeight="0.5" order="0" 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="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" />
<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="10" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3840399" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" 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="0" side_tool="false" content_ui="tabs" />
<window_info id="PHP-CGI Server" 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="9" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3990025" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Command Line Tools Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3316583" sideWeight="0.5" order="11" 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="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="Ant Build" 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="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
@ -801,8 +819,6 @@
</component>
<component name="VcsManagerConfiguration">
<option name="USE_COMMIT_MESSAGE_MARGIN" value="true" />
<MESSAGE value="Split Table and Map to the separate classes for decoupling" />
<MESSAGE value="Introduce index.php and require autoload.php in tests" />
<MESSAGE value="Implement Tile.getNeighbors" />
<MESSAGE value="Refactor Tile constructor to accept parameters&#10;" />
<MESSAGE value="Refactor Table constructor to accept arguments" />
@ -826,7 +842,9 @@
<MESSAGE value="Rework Table constructor" />
<MESSAGE value="Composer update" />
<MESSAGE value="Implement recursive algoritm to find one large spot" />
<option name="LAST_COMMIT_MESSAGE" value="Implement recursive algoritm to find one large spot" />
<MESSAGE value="Implement recursive algorithm to find Spots" />
<MESSAGE value="Implement Spot size" />
<option name="LAST_COMMIT_MESSAGE" value="Implement Spot size" />
<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" />
@ -857,6 +875,62 @@
</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">
<caret line="72" column="20" selection-start-line="72" selection-start-column="20" selection-end-line="72" selection-end-column="20" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.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/Coffee/PositionTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
<caret line="42" column="29" selection-start-line="42" selection-start-column="29" selection-end-line="42" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.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$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.0">
@ -1016,7 +1090,6 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.740741">
<caret line="46" column="0" selection-start-line="46" selection-start-column="0" selection-end-line="46" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
@ -1024,7 +1097,6 @@
<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" />
<folding />
</state>
</provider>
</entry>
@ -1032,7 +1104,6 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.4074073">
<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>
@ -1040,7 +1111,6 @@
<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" />
<folding />
</state>
</provider>
</entry>
@ -1055,7 +1125,6 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.4074074">
<caret line="11" column="0" selection-start-line="11" selection-start-column="0" selection-end-line="11" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
@ -1063,7 +1132,6 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.40123457">
<caret line="32" column="0" selection-start-line="32" selection-start-column="0" selection-end-line="32" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
@ -1071,7 +1139,6 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.35185185">
<caret line="155" column="9" selection-start-line="155" selection-start-column="9" selection-end-line="155" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
@ -1079,7 +1146,6 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.33333334">
<caret line="27" column="0" selection-start-line="27" selection-start-column="0" selection-end-line="27" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
@ -1087,7 +1153,6 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.3901869">
<caret line="37" column="42" selection-start-line="37" selection-start-column="42" selection-end-line="37" selection-end-column="42" />
<folding />
</state>
</provider>
</entry>
@ -1095,102 +1160,99 @@
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.29752067">
<caret line="8" column="5" selection-start-line="8" selection-start-column="5" selection-end-line="8" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php">
<entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-18.660378">
<caret line="103" column="76" selection-start-line="103" selection-start-column="76" selection-end-line="103" selection-end-column="76" />
<folding />
<state vertical-scroll-proportion="-8.0">
<caret line="12" column="0" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/SpotTest.php">
<entry file="file:///usr/share/nginx/html/coffeetable/src/Coffee/Table.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 vertical-scroll-proportion="0.7222222">
<caret line="102" column="26" selection-start-line="102" selection-start-column="26" selection-end-line="102" selection-end-column="26" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php">
<entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-8.0">
<caret line="12" column="0" selection-start-line="12" selection-start-column="0" selection-end-line="12" selection-end-column="0" />
<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$/tests/Coffee/TileTest.php">
<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="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="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="-48.0">
<state vertical-scroll-proportion="0.0">
<caret line="72" column="20" selection-start-line="72" selection-start-column="20" selection-end-line="72" selection-end-column="20" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-33.037037">
<caret line="147" column="0" selection-start-line="147" selection-start-column="0" selection-end-line="147" selection-end-column="0" />
<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$/src/Coffee/Position.php">
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-11.0">
<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="0.0">
<caret line="42" column="29" selection-start-line="42" selection-start-column="29" selection-end-line="42" selection-end-column="29" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<entry file="file://$PROJECT_DIR$/tests/Coffee/SpotTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-20.0">
<caret line="35" column="19" selection-start-line="35" selection-start-column="19" selection-end-line="35" selection-end-column="19" />
<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:///usr/share/nginx/html/coffeetable/src/Coffee/Table.php">
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.7222222">
<caret line="102" column="26" selection-start-line="102" selection-start-column="26" selection-end-line="102" selection-end-column="26" />
<state vertical-scroll-proportion="0.0">
<caret line="30" column="26" selection-start-line="30" selection-start-column="26" selection-end-line="30" selection-end-column="26" />
<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="-57.703705">
<caret line="91" column="5" selection-start-line="91" selection-start-column="5" selection-end-line="91" selection-end-column="5" />
<state vertical-scroll-proportion="-17.0">
<caret line="47" column="7" selection-start-line="47" selection-start-column="7" selection-end-line="47" selection-end-column="7" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/TableTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="6.296296">
<caret line="47" column="56" selection-start-line="47" selection-start-column="56" selection-end-line="47" selection-end-column="56" />
<state vertical-scroll-proportion="-11.703704">
<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$/index.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.45721924">
<caret line="19" column="0" selection-start-line="19" selection-start-column="0" selection-end-line="19" selection-end-column="0" />
<state vertical-scroll-proportion="0.2603306">
<caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="22" selection-end-column="35" />
<folding />
</state>
</provider>

@ -5,18 +5,22 @@ namespace Coffee;
require __DIR__ . '/vendor/autoload.php';
try {
$description = [
[0, 1, 0, 1],
[1, 0, 0, 0],
[0, 0, 0, 1],
[0, 0, 1, 1]
];
$map = new Map($description);
$table = new Table($map);
var_dump($table->getSpots());
// $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);
}
catch (\Exception $e) {

@ -20,15 +20,15 @@ class Spot {
*/
private $positions = [];
private $size = 0;
/**
* Spot constructor.
*
* @param Position $position
*/
public function __construct(Position $position) {
// if (!is_null($position)) {
$this->positions[] = $position;
// }
$this->addPosition($position);
}
/**
@ -40,6 +40,7 @@ class Spot {
return false;
}
$this->size++;
$this->positions[] = $position;
return true;
}
@ -51,4 +52,11 @@ class Spot {
return $this->positions;
}
/**
* @return int
*/
public function getSize() {
return $this->size;
}
}

@ -2,11 +2,7 @@
namespace Coffee;
/**
* Class Table
*
* @package Coffee
*/
/**
* Class Table
*
@ -29,6 +25,8 @@ class Table {
*/
private $currentSpot = null;
private $largestSize = 0;
/**
* Table constructor.
*
@ -37,7 +35,7 @@ class Table {
public function __construct(Map $map) {
$this->map = $map;
$this->recur();
$this->recurseMap();
}
/**
@ -54,10 +52,21 @@ class Table {
return count($this->spots);
}
/**
* @return int
*/
public function getLargestSpotSize() {
return $this->largestSize;
}
public function getSpotIndexByPosition(Position $position) {
}
/**
* @param Tile|null $tile
*/
protected function recur($tile = null) {
protected function recurseMap($tile = null) {
$tiles = $this->getNextTile($tile);
foreach ($tiles as $currentTile) {
@ -68,20 +77,8 @@ class Table {
$this->updateCurrentSpot($currentTile->getPosition());
// Recursion?
// $tiles = $this->getNextTile($currentTile);
// foreach ($tiles as $neighbouringTile) {
//
// if (!$neighbouringTile->isVisited()) {
// $neighbouringTile->visit();
//
// if ($neighbouringTile->isRepresentingSpot()) {
// $this->updateCurrentSpot($neighbouringTile->getPosition());
// }
//
// }
// }
$this->recur($currentTile);
// Recursion
$this->recurseMap($currentTile);
$this->addCurrentSpot();
@ -91,6 +88,9 @@ class Table {
}
}
/**
* @param Position $position
*/
protected function updateCurrentSpot(Position $position) {
if (is_null($this->currentSpot)) {
$this->currentSpot = new Spot($position);
@ -108,6 +108,10 @@ class Table {
return false;
}
$size = $this->currentSpot->getSize();
// Maximum size
$this->largestSize = $size > $this->largestSize ? $size : $this->largestSize;
$this->spots[] = $this->currentSpot;
$this->currentSpot = null;
return true;
@ -117,7 +121,7 @@ class Table {
* @param $tile
* @return Tile[]
*/
private function getNextTile($tile = null) {
protected function getNextTile($tile = null) {
if (is_null($tile)) {
$tiles = $this->map->getTiles();
return $tiles;

@ -13,4 +13,15 @@ class SpotTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals([$position], $spot->getPositions());
}
public function testSize() {
$spotA = new Spot(new Position(1, 2));
$spotA->addPosition(new Position(1, 3));
$spotA->addPosition(new Position(2, 3));
$spotA->addPosition(new Position(3, 2));
$spotA->addPosition(new Position(4, 1));
$this->assertEquals(5, $spotA->getSize());
}
}

@ -103,4 +103,31 @@ class TableTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals([$spotA, $spotB], $table->getSpots());
}
public function testLargestSpotSize() {
$map = new Map([
[0, 1, 1, 0, 0],
[1, 1, 1, 0, 1],
[0, 0, 1, 0, 1],
[1, 0, 0, 0, 0],
]);
$table = new Table($map);
$this->assertEquals(6, $table->getLargestSpotSize());
}
// public function testSpotIndexByPosition() {
// $map = new Map([
// [0, 1, 1, 0, 0],
// [1, 1, 1, 0, 1],
// [0, 0, 1, 0, 1],
// [1, 0, 0, 0, 0],
// ]);
//
// $table = new Table($map);
// $position = new Position(1, 2);
//
// $this->assertEquals(1, $table->getSpotIndexByPosition($position));
// }
}

Loading…
Cancel
Save