Implemet Tile.getPosition

master
Peter Babič 8 years ago
parent 790181fec3
commit 53ea4f589e
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 115
      .idea/workspace.xml
  2. 4
      index.php
  3. 12
      src/Coffee/Tile.php
  4. 15
      tests/Coffee/TileTest.php

@ -4,10 +4,7 @@
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Implement Map.getTileByPosition and do some refactoring">
<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/Position.php" afterPath="$PROJECT_DIR$/src/Coffee/Position.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Coffee/Tile.php" afterPath="$PROJECT_DIR$/src/Coffee/Tile.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/TileTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/TileTest.php" />
</list>
<ignored path="coffeetable.iws" />
@ -34,11 +31,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.10743801">
<caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="20" selection-end-column="5" />
<state vertical-scroll-proportion="-4.6666665">
<caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="22" selection-end-column="5" />
<folding />
</state>
</provider>
@ -87,8 +84,8 @@
<file leaf-file-name="Map.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-98.666664">
<caret line="148" column="22" selection-start-line="148" selection-start-column="22" selection-end-line="148" selection-end-column="22" />
<state vertical-scroll-proportion="-13.407408">
<caret line="133" column="0" selection-start-line="133" selection-start-column="0" selection-end-line="133" selection-end-column="0" />
<folding />
</state>
</provider>
@ -97,7 +94,7 @@
<file leaf-file-name="MapTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-10.0">
<state vertical-scroll-proportion="22.962963">
<caret line="33" column="71" selection-start-line="33" selection-start-column="71" selection-end-line="33" selection-end-column="71" />
<folding />
</state>
@ -114,11 +111,21 @@
</provider>
</entry>
</file>
<file leaf-file-name="Tile.php" pinned="false" current-in-tab="false">
<file leaf-file-name="Tile.php" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-21.037037">
<caret line="45" column="37" selection-start-line="45" selection-start-column="37" selection-end-line="45" selection-end-column="37" />
<state vertical-scroll-proportion="0.99642855">
<caret line="58" column="65" selection-start-line="58" selection-start-column="65" selection-end-line="58" selection-end-column="65" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="TileTest.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-14.666667">
<caret line="22" column="61" selection-start-line="22" selection-start-column="61" selection-end-line="22" selection-end-column="61" />
<folding />
</state>
</provider>
@ -165,15 +172,15 @@
<option value="$PROJECT_DIR$/composer.json" />
<option value="$PROJECT_DIR$/tests/Coffee/SpotTest.php" />
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Map.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TileTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Tile.php" />
<option value="$PROJECT_DIR$/tests/Coffee/PositionTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/MapTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Map.php" />
<option value="$PROJECT_DIR$/src/Coffee/Tile.php" />
<option value="$PROJECT_DIR$/src/Coffee/Position.php" />
<option value="$PROJECT_DIR$/index.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TileTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Tile.php" />
</list>
</option>
</component>
@ -658,38 +665,44 @@
<option name="project" value="LOCAL" />
<updated>1458243697414</updated>
</task>
<option name="localTasksCounter" value="23" />
<task id="LOCAL-00023" summary="Implement Map.getTileByPosition and do some refactoring">
<created>1458244258939</created>
<option name="number" value="00023" />
<option name="project" value="LOCAL" />
<updated>1458244258939</updated>
</task>
<option name="localTasksCounter" value="24" />
<servers />
</component>
<component name="TestHistory">
<history-entry file="Tests - 2016.03.17 at 18h 38m 42s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 37m 08s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 18h 41m 22s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 38m 52s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 19h 14m 06s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 39m 58s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 20h 29m 36s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 40m 42s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 20h 33m 59s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 49m 33s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 20h 37m 08s.xml">
<history-entry file="Tests - 2016.03.17 at 20h 58m 59s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 20h 38m 52s.xml">
<history-entry file="Tests - 2016.03.17 at 21h 01m 47s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 20h 39m 58s.xml">
<history-entry file="Tests - 2016.03.17 at 21h 02m 30s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 20h 40m 42s.xml">
<history-entry file="Tests - 2016.03.17 at 21h 07m 14s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.17 at 20h 49m 33s.xml">
<history-entry file="Tests - 2016.03.17 at 21h 08m 05s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
</component>
@ -699,12 +712,12 @@
<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.16875" 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.23441397" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" x="0" y="355" width="1446" height="188" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23441397" 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" />
@ -762,7 +775,7 @@
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<option name="time" value="30" />
<option name="time" value="31" />
</breakpoint-manager>
<watches-manager />
</component>
@ -1038,14 +1051,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.3333335">
<caret line="8" column="0" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="phar:///usr/share/webapps/bin/phpunit.phar/phpunit/Framework/TestFailure.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-5.740741">
@ -1117,42 +1122,50 @@
</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="-10.0">
<caret line="33" column="71" selection-start-line="33" selection-start-column="71" selection-end-line="33" selection-end-column="71" />
<state vertical-scroll-proportion="-11.333333">
<caret line="155" column="44" selection-start-line="155" selection-start-column="44" selection-end-line="155" selection-end-column="44" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-98.666664">
<caret line="148" column="22" selection-start-line="148" selection-start-column="22" selection-end-line="148" selection-end-column="22" />
<state vertical-scroll-proportion="-4.6666665">
<caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="22" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<entry file="file://$PROJECT_DIR$/tests/Coffee/MapTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-21.037037">
<caret line="45" column="37" selection-start-line="45" selection-start-column="37" selection-end-line="45" selection-end-column="37" />
<state vertical-scroll-proportion="22.962963">
<caret line="33" column="71" selection-start-line="33" selection-start-column="71" selection-end-line="33" selection-end-column="71" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Position.php">
<entry file="file://$PROJECT_DIR$/src/Coffee/Map.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-11.333333">
<caret line="155" column="44" selection-start-line="155" selection-start-column="44" selection-end-line="155" selection-end-column="44" />
<state vertical-scroll-proportion="-13.407408">
<caret line="133" column="0" selection-start-line="133" selection-start-column="0" selection-end-line="133" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.php">
<entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-14.666667">
<caret line="22" column="61" selection-start-line="22" selection-start-column="61" selection-end-line="22" selection-end-column="61" />
<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.10743801">
<caret line="7" column="0" selection-start-line="7" selection-start-column="2" selection-end-line="20" selection-end-column="5" />
<state vertical-scroll-proportion="0.99642855">
<caret line="58" column="65" selection-start-line="58" selection-start-column="65" selection-end-line="58" selection-end-column="65" />
<folding />
</state>
</provider>

@ -15,8 +15,10 @@ try {
// $table = new Table();
//
// foreach ($map->getUnVisitedTiles() as $unVisitedTile) {
//// $map->vi
// foreach ($unVisitedTile->getNeighbouringPositions() as $neighbouringPosition) {
// ;
// $tile = $map->getTileByPosition($neighbouringPosition);
//// if
// }
// }
}

@ -2,6 +2,11 @@
namespace Coffee;
/**
* Class Tile
*
* @package Coffee
*/
/**
* Class Tile
*
@ -47,4 +52,11 @@ class Tile extends Position {
return $this->containsElement == self::REPRESENTS_ELEMENT;
}
/**
* @return Position
*/
public function getPosition() {
return new Position($this->getRow(), $this->getColumn());
}
}

@ -7,9 +7,20 @@ require __DIR__ . '/../../vendor/autoload.php';
class TileTest extends \PHPUnit_Framework_TestCase {
public function testContainsElement() {
$tile = new Tile(2, 2, true);
public function testRepresentsElement() {
$tile = new Tile(2, 2, Tile::REPRESENTS_ELEMENT);
$this->assertTrue($tile->representsElement());
}
public function testGetPosition() {
$row = 2;
$column = 2;
$tile = new Tile($row, $column, Tile::REPRESENTS_VOID);
$position = new Position($row, $column);
$this->assertEquals($position, $tile->getPosition());
}
}

Loading…
Cancel
Save