Implement Spot.getNumber

master
Peter Babič 8 years ago
parent 36494332a0
commit 01360873b4
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 137
      .idea/workspace.xml
  2. 9
      index.php
  3. 16
      src/Coffee/Spot.php
  4. 4
      tests/Coffee/SpotTest.php
  5. 11
      tests/Coffee/TileTest.php

@ -7,9 +7,8 @@
<list default="true" id="65f95bb6-3a86-4ed6-841e-441936291ad4" name="Default" comment="Present second version with valid Spots output">
<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/Table.php" afterPath="$PROJECT_DIR$/src/Coffee/Table.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/TableTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Coffee/Spot.php" afterPath="$PROJECT_DIR$/src/Coffee/Spot.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/TileTest.php" afterPath="$PROJECT_DIR$/tests/Coffee/TileTest.php" />
</list>
<ignored path="coffeetable.iws" />
@ -36,21 +35,21 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="index.php" pinned="false" current-in-tab="false">
<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="-19.333334">
<caret line="29" column="0" selection-start-line="29" selection-start-column="0" selection-end-line="29" selection-end-column="0" />
<state vertical-scroll-proportion="0.5294118">
<caret line="22" column="34" selection-start-line="22" selection-start-column="34" selection-end-line="22" selection-end-column="34" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Table.php" pinned="false" current-in-tab="true">
<file leaf-file-name="Table.php" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="3.268595">
<caret line="119" column="0" selection-start-line="119" selection-start-column="0" selection-end-line="119" selection-end-column="0" />
<state vertical-scroll-proportion="-39.037037">
<caret line="120" column="0" selection-start-line="120" selection-start-column="0" selection-end-line="120" selection-end-column="0" />
<folding />
</state>
</provider>
@ -59,7 +58,7 @@
<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="-12.666667">
<state vertical-scroll-proportion="6.0">
<caret line="27" column="0" selection-start-line="27" selection-start-column="0" selection-end-line="27" selection-end-column="0" />
<folding />
</state>
@ -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="10.296296">
<caret line="20" column="6" selection-start-line="20" selection-start-column="6" selection-end-line="20" selection-end-column="6" />
<state vertical-scroll-proportion="-11.703704">
<caret line="67" column="0" selection-start-line="67" selection-start-column="0" selection-end-line="67" selection-end-column="0" />
<folding />
</state>
</provider>
@ -99,8 +98,8 @@
<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="-15.814815">
<caret line="35" column="1" selection-start-line="35" selection-start-column="1" selection-end-line="35" selection-end-column="1" />
<state vertical-scroll-proportion="-20.0">
<caret line="30" column="0" selection-start-line="30" selection-start-column="0" selection-end-line="30" selection-end-column="0" />
<folding />
</state>
</provider>
@ -109,7 +108,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="34.185184">
<state vertical-scroll-proportion="26.296297">
<caret line="37" column="12" selection-start-line="37" selection-start-column="12" selection-end-line="37" selection-end-column="12" />
<folding />
</state>
@ -119,8 +118,8 @@
<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="-12.962963">
<caret line="41" column="17" selection-start-line="41" selection-start-column="17" selection-end-line="41" selection-end-column="17" />
<state vertical-scroll-proportion="-14.0">
<caret line="21" column="0" selection-start-line="21" selection-start-column="0" selection-end-line="21" selection-end-column="0" />
<folding />
</state>
</provider>
@ -174,15 +173,15 @@
<option value="$PROJECT_DIR$/src/Coffee/Map.php" />
<option value="$PROJECT_DIR$/tests/Coffee/PositionTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Position.php" />
<option value="$PROJECT_DIR$/tests/Coffee/SpotTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Spot.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TableTest.php" />
<option value="$PROJECT_DIR$/src/Coffee/Tile.php" />
<option value="/usr/share/nginx/html/coffeetable/tests/Coffee/TileTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TileTest.php" />
<option value="/usr/share/nginx/html/coffeetable/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/index.php" />
<option value="$PROJECT_DIR$/src/Coffee/Table.php" />
<option value="$PROJECT_DIR$/src/Coffee/Spot.php" />
<option value="$PROJECT_DIR$/tests/Coffee/SpotTest.php" />
<option value="$PROJECT_DIR$/tests/Coffee/TileTest.php" />
<option value="$PROJECT_DIR$/index.php" />
</list>
</option>
</component>
@ -818,19 +817,16 @@
<option name="project" value="LOCAL" />
<updated>1458516661818</updated>
</task>
<option name="localTasksCounter" value="48" />
<task id="LOCAL-00048" summary="Present second version with valid Spots output">
<created>1458519662082</created>
<option name="number" value="00048" />
<option name="project" value="LOCAL" />
<updated>1458519662082</updated>
</task>
<option name="localTasksCounter" value="49" />
<servers />
</component>
<component name="TestHistory">
<history-entry file="Tests - 2016.03.21 at 00h 54m 14s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.21 at 00h 54m 21s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.21 at 00h 54m 50s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.21 at 00h 57m 18s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
@ -852,6 +848,15 @@
<history-entry file="Tests - 2016.03.21 at 01h 19m 31s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.21 at 01h 30m 37s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.21 at 01h 31m 21s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
<history-entry file="Tests - 2016.03.21 at 01h 31m 52s.xml">
<configuration name="Tests" configurationId="PHPUnitRunConfigurationType" />
</history-entry>
</component>
<component name="TodoView" selected-index="4">
<todo-panel id="selected-file">
@ -868,7 +873,7 @@
<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.17222223" 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.32917705" 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" />
@ -1249,14 +1254,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/SpotTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-15.814815">
<caret line="35" column="1" selection-start-line="35" selection-start-column="1" selection-end-line="35" selection-end-column="1" />
<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.22860962">
@ -1273,14 +1270,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="-12.962963">
<caret line="41" column="17" selection-start-line="41" selection-start-column="17" selection-end-line="41" selection-end-column="17" />
<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="-6.5925927">
@ -1297,50 +1286,66 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.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="34.185184">
<caret line="37" column="12" selection-start-line="37" selection-start-column="12" selection-end-line="37" selection-end-column="12" />
<state vertical-scroll-proportion="2.4411216">
<caret line="134" column="0" selection-start-line="134" selection-start-column="0" selection-end-line="134" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/tests/Coffee/TableTest.php">
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-12.666667">
<caret line="27" column="0" selection-start-line="27" selection-start-column="0" selection-end-line="27" selection-end-column="0" />
<state vertical-scroll-proportion="-39.037037">
<caret line="120" column="0" selection-start-line="120" selection-start-column="0" selection-end-line="120" 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="2.4411216">
<caret line="134" column="0" selection-start-line="134" selection-start-column="0" selection-end-line="134" selection-end-column="0" />
<state vertical-scroll-proportion="-11.703704">
<caret line="67" column="0" selection-start-line="67" selection-start-column="0" selection-end-line="67" selection-end-column="0" />
<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="10.296296">
<caret line="20" column="6" selection-start-line="20" selection-start-column="6" selection-end-line="20" selection-end-column="6" />
<state vertical-scroll-proportion="-20.0">
<caret line="30" column="0" selection-start-line="30" selection-start-column="0" selection-end-line="30" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.php">
<entry file="file://$PROJECT_DIR$/src/Coffee/Tile.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-19.333334">
<caret line="29" column="0" selection-start-line="29" selection-start-column="0" selection-end-line="29" selection-end-column="0" />
<state vertical-scroll-proportion="26.296297">
<caret line="37" column="12" selection-start-line="37" selection-start-column="12" selection-end-line="37" selection-end-column="12" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Coffee/Table.php">
<entry file="file://$PROJECT_DIR$/tests/Coffee/TileTest.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="-14.0">
<caret line="21" column="0" selection-start-line="21" selection-start-column="0" selection-end-line="21" selection-end-column="0" />
<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.0">
<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>
<entry file="file://$PROJECT_DIR$/index.php">
<provider selected="true" editor-type-id="text-editor">
<state vertical-scroll-proportion="3.268595">
<caret line="119" column="0" selection-start-line="119" selection-start-column="0" selection-end-line="119" selection-end-column="0" />
<state vertical-scroll-proportion="0.5294118">
<caret line="22" column="34" selection-start-line="22" selection-start-column="34" selection-end-line="22" selection-end-column="34" />
<folding />
</state>
</provider>

@ -19,15 +19,16 @@ try {
echo '<tr>' . "\n";
/** @var Tile $tile */
foreach ($row as $tile) {
$formattedTile = $tile->getSpotNumber() == 0 ? '' : $tile->getSpotNumber();
echo '<td>' . $formattedTile . '</td>' . "\n";
// $formattedTile = $tile->getSpotNumber() == 0 ? '' : $tile->getSpotNumber();
echo '<td>' . $tile->getSpotNumber() . '</td>' . "\n";
}
echo '</tr>' . "\n";
}
echo '</table>' . "\n";
// echo 'Najväčšia kávová kaluž je s číslom '.$table->getLargestSpot()->ge
echo 'Najväčšia kávová kaluž je s číslom ' . $table->getLargestSpot()->getNumber() . '<br>' . "\n";
echo 'Kaluž je veľká ' . $table->getLargestSpot()->getSize() . ' políčok.</br>' . "\n";
echo 'Počet kaluží je: ' . $table->getSpotsCount() . '<br>' . "\n";
}
catch (\Exception $e) {
// TODO: provide more information, like the file:line for example

@ -25,6 +25,11 @@ class Spot {
*/
private $tiles = [];
/**
* @var int
*/
private $number = 0;
/**
* Spot constructor.
*
@ -62,9 +67,18 @@ class Spot {
}
/**
* @param $number
* @return int
*/
public function getNumber() {
return $this->number;
}
/**
* @param int $number
*/
public function setNumber($number) {
$this->number = $number;
foreach ($this->getTiles() as $tile) {
$tile->setSpotNumber($number);
}

@ -28,9 +28,7 @@ class SpotTest extends \PHPUnit_Framework_TestCase {
$spot = new Spot(new Tile(1, 2));
$spot->setNumber(3);
$tiles = $spot->getTiles();
$this->assertEquals(3, $tiles[0]->getSpotNumber());
$this->assertEquals(3, $spot->getNumber());
}
}

@ -19,17 +19,6 @@ class TileTest extends \PHPUnit_Framework_TestCase {
$this->assertTrue($tile->isRepresentingVoid());
}
// public function testGetPosition() {
// $row = 2;
// $column = 2;
//
// $tile = new Tile($row, $column, Tile::REPRESENTS_VOID);
// $position = new Tile($row, $column);
//
// $this->assertEquals($position, $tile->getPosition());
//
// }
public function testIsVisited() {
$tile = new Tile(2, 2, Tile::REPRESENTS_SPOT);
$tile->visit();

Loading…
Cancel
Save