Refactor largest Spot and its size

master
Peter Babič 8 years ago
parent 30ef9912b4
commit 7b620b11b2
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 148
      .idea/workspace.xml
  2. 4
      src/Coffee/Spot.php
  3. 40
      src/Coffee/Table.php
  4. 4
      tests/Coffee/PositionTest.php
  5. 2
      tests/Coffee/TableTest.php

@ -4,12 +4,11 @@
<option name="ANALYZE_TEST_SOURCES" value="false" />
</component>
<component name="ChangeListManager">
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Implement Spot size">
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Refactor largest Spot">
<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/PositionTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/PositionTest.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/tests/Coffee/TableTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
</list>
<ignored path="coffeetable.iws" />
@ -36,11 +35,11 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="index.php" pinned="false" current-in-tab="true">
<file leaf-file-name="index.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.2603306">
<caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="22" selection-end-column="35" />
<state vertical-scroll-proportion="-10.666667">
<caret line="16" column="48" selection-start-line="16" selection-start-column="48" selection-end-line="16" selection-end-column="48" />
<folding />
</state>
</provider>
@ -49,8 +48,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="-17.0">
<caret line="47" column="7" selection-start-line="47" selection-start-column="7" selection-end-line="47" selection-end-column="7" />
<state vertical-scroll-proportion="-39.333332">
<caret line="59" column="5" selection-start-line="59" selection-start-column="5" selection-end-line="59" selection-end-column="5" />
<folding />
</state>
</provider>
@ -59,8 +58,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="-11.703704">
<caret line="115" column="0" selection-start-line="115" selection-start-column="0" selection-end-line="115" selection-end-column="0" />
<state vertical-scroll-proportion="-3.402439">
<caret line="116" column="66" selection-start-line="116" selection-start-column="66" selection-end-line="116" selection-end-column="66" />
<folding />
</state>
</provider>
@ -69,8 +68,8 @@
<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="0.0">
<caret line="30" column="26" selection-start-line="30" selection-start-column="26" selection-end-line="30" selection-end-column="26" />
<state vertical-scroll-proportion="-21.037037">
<caret line="55" column="23" selection-start-line="55" selection-start-column="23" selection-end-line="55" selection-end-column="23" />
<folding />
</state>
</provider>
@ -89,7 +88,7 @@
<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="0.0">
<state vertical-scroll-proportion="-102.51852">
<caret line="175" column="23" selection-start-line="175" selection-start-column="23" selection-end-line="175" selection-end-column="23" />
<folding />
</state>
@ -126,11 +125,11 @@
</provider>
</entry>
</file>
<file leaf-file-name="PositionTest.php" pinned="false" current-in-tab="false">
<file leaf-file-name="PositionTest.php" pinned="false" current-in-tab="true">
<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" />
<state vertical-scroll-proportion="-1.8636364">
<caret line="21" column="37" selection-start-line="21" selection-start-column="37" selection-end-line="21" selection-end-column="37" />
<folding />
</state>
</provider>
@ -179,18 +178,18 @@
<option value="/usr/share/nginx/html/coffeetable/index.php" />
<option value="$PROJECT_DIR$/src/Coffee/Tile.php" />
<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/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="$PROJECT_DIR$/tests/Coffee/SpotTest.php" />
<option value="$PROJECT_DIR$/index.php" />
<option value="$PROJECT_DIR$/src/Coffee/Spot.php" />
<option value="$PROJECT_DIR$/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
<option value="$PROJECT_DIR$/index.php" />
<option value="$PROJECT_DIR$/tests/Coffee/PositionTest.php" />
</list>
</option>
</component>
@ -742,38 +741,50 @@
<option name="project" value="LOCAL" />
<updated>1458308469594</updated>
</task>
<option name="localTasksCounter" value="34" />
<task id="LOCAL-00034" summary="Implement Spot size">
<created>1458490339326</created>
<option name="number" value="00034" />
<option name="project" value="LOCAL" />
<updated>1458490339326</updated>
</task>
<task id="LOCAL-00035" summary="Refactor largest Spot">
<created>1458499267611</created>
<option name="number" value="00035" />
<option name="project" value="LOCAL" />
<updated>1458499267612</updated>
</task>
<option name="localTasksCounter" value="36" />
<servers />
</component>
<component name="TestHistory">
<history-entry file="Tests - 2016.03.19 at 11h 46m 05s.xml">
<history-entry file="Tests - 2016.03.20 at 19h 27m 31s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.19 at 12h 42m 05s.xml">
<history-entry file="Tests - 2016.03.20 at 19h 28m 04s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.19 at 12h 46m 21s.xml">
<history-entry file="Tests - 2016.03.20 at 19h 30m 16s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.19 at 13h 15m 08s.xml">
<history-entry file="Tests - 2016.03.20 at 19h 36m 41s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.19 at 13h 15m 15s.xml">
<history-entry file="Tests - 2016.03.20 at 19h 36m 47s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.19 at 13h 15m 23s.xml">
<history-entry file="Tests - 2016.03.20 at 19h 37m 45s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.19 at 13h 15m 27s.xml">
<history-entry file="Tests - 2016.03.20 at 19h 42m 31s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.20 at 17h 03m 49s.xml">
<history-entry file="Tests - 2016.03.20 at 19h 45m 45s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.20 at 17h 03m 55s.xml">
<history-entry file="Tests - 2016.03.20 at 19h 47m 05s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.20 at 17h 11m 17s.xml">
<history-entry file="Tests - 2016.03.20 at 19h 47m 37s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
</component>
@ -783,15 +794,16 @@
<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="true" 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="false" show_stripe_button="true" weight="0.32917705" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="12" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32917705" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32917705" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32668328" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" x="0" y="355" width="1446" height="188" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24964234" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<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="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3241895" 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" />
@ -799,7 +811,6 @@
<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>
@ -819,7 +830,6 @@
</component>
<component name="VcsManagerConfiguration">
<option name="USE_COMMIT_MESSAGE_MARGIN" value="true" />
<MESSAGE value="Implement Tile.getNeighbors" />
<MESSAGE value="Refactor Tile constructor to accept parameters&#10;" />
<MESSAGE value="Refactor Table constructor to accept arguments" />
<MESSAGE value="Implement Map.isValidPosition" />
@ -844,7 +854,8 @@
<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" />
<MESSAGE value="Refactor largest Spot" />
<option name="LAST_COMMIT_MESSAGE" value="Refactor largest Spot" />
<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" />
@ -854,14 +865,14 @@
<breakpoints>
<line-breakpoint enabled="true" type="php">
<url>file://$PROJECT_DIR$/tests/Coffee/TableTest.php</url>
<line>45</line>
<option name="timeStamp" value="37" />
<line>107</line>
<option name="timeStamp" value="40" />
</line-breakpoint>
</breakpoints>
<breakpoints-dialog>
<breakpoints-dialog />
</breakpoints-dialog>
<option name="time" value="38" />
<option name="time" value="42" />
</breakpoint-manager>
<watches-manager>
<configuration name="PhpLocalRunConfigurationType">
@ -1100,13 +1111,6 @@
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestCase.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.4074073">
<caret line="802" column="0" selection-start-line="802" selection-start-column="0" selection-end-line="802" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestSuite.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.740741">
@ -1177,14 +1181,6 @@
</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">
@ -1209,50 +1205,66 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php">
<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="42" column="29" selection-start-line="42" selection-start-column="29" selection-end-line="42" selection-end-column="29" />
<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$/tests/Coffee/SpotTest.php">
<entry file="file://$PROJECT_DIR$/index.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" />
<state vertical-scroll-proportion="-10.666667">
<caret line="16" column="48" selection-start-line="16" selection-start-column="48" selection-end-line="16" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestCase.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="0.31893003">
<caret line="985" column="0" selection-start-line="985" selection-start-column="0" selection-end-line="985" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Spot.php">
<provider selected="true" editor-type-id="text-editor">
<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" />
<state vertical-scroll-proportion="-21.037037">
<caret line="55" column="23" selection-start-line="55" selection-start-column="23" selection-end-line="55" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/TableTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-3.402439">
<caret line="116" column="66" selection-start-line="116" selection-start-column="66" selection-end-line="116" selection-end-column="66" />
<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="-17.0">
<caret line="47" column="7" selection-start-line="47" selection-start-column="7" selection-end-line="47" selection-end-column="7" />
<state vertical-scroll-proportion="-39.333332">
<caret line="59" column="5" selection-start-line="59" selection-start-column="5" selection-end-line="59" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/TableTest.php">
<entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<provider selected="true" editor-type-id="text-editor">
<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" />
<state vertical-scroll-proportion="-102.51852">
<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$/index.php">
<entry file="file://$PROJECT_DIR$/tests/Coffee/PositionTest.php">
<provider selected="true" editor-type-id="text-editor">
<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" />
<state vertical-scroll-proportion="-1.8636364">
<caret line="21" column="37" selection-start-line="21" selection-start-column="37" selection-end-line="21" selection-end-column="37" />
<folding />
</state>
</provider>

@ -20,7 +20,6 @@ class Spot {
*/
private $positions = [];
private $size = 0;
/**
* Spot constructor.
@ -40,7 +39,6 @@ class Spot {
return false;
}
$this->size++;
$this->positions[] = $position;
return true;
}
@ -56,7 +54,7 @@ class Spot {
* @return int
*/
public function getSize() {
return $this->size;
return count($this->positions);
}
}

@ -2,7 +2,11 @@
namespace Coffee;
/**
* Class Table
*
* @package Coffee
*/
/**
* Class Table
*
@ -25,7 +29,10 @@ class Table {
*/
private $currentSpot = null;
private $largestSize = 0;
/**
* @var Spot
*/
private $largestSpot = null;
/**
* Table constructor.
@ -53,12 +60,15 @@ class Table {
}
/**
* @return int
* @return Spot
*/
public function getLargestSpotSize() {
return $this->largestSize;
public function getLargestSpot() {
return $this->largestSpot;
}
/**
* @param Position $position
*/
public function getSpotIndexByPosition(Position $position) {
}
@ -80,7 +90,7 @@ class Table {
// Recursion
$this->recurseMap($currentTile);
$this->addCurrentSpot();
$this->addCurrentSpot(); // (to this table)
}
}
@ -108,9 +118,7 @@ class Table {
return false;
}
$size = $this->currentSpot->getSize();
// Maximum size
$this->largestSize = $size > $this->largestSize ? $size : $this->largestSize;
$this->updateLargestSpot();
$this->spots[] = $this->currentSpot;
$this->currentSpot = null;
@ -132,4 +140,18 @@ class Table {
}
}
/**
* Just a wrapper to have it neat and clean
*/
protected function updateLargestSpot() {
if (is_null($this->largestSpot)) {
$this->largestSpot = $this->currentSpot;
}
$currentSize = is_null($this->largestSpot) ? 0 : $this->currentSpot->getSize();
$largestSize = is_null($this->largestSpot) ? 0 : $this->largestSpot->getSize();
// Maximum size
$this->largestSpot = $currentSize > $largestSize ? $this->currentSpot : $this->largestSpot;
}
}

@ -19,14 +19,14 @@ class PositionTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals(1, $position->getRowIndex());
}
public function testTheSameX() {
public function testTheSameColumn() {
$positionA = new Position(2, 2);
$positionB = new Position(2, 2);
$this->assertTrue($positionA->isTheSameColumn($positionB));
}
public function testTheSameY() {
public function testTheSameRow() {
$positionA = new Position(2, 2);
$positionB = new Position(2, 2);

@ -114,7 +114,7 @@ class TableTest extends \PHPUnit_Framework_TestCase {
$table = new Table($map);
$this->assertEquals(6, $table->getLargestSpotSize());
$this->assertEquals(6, $table->getLargestSpot()->getSize());
}
// public function testSpotIndexByPosition() {

Loading…
Cancel
Save