Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions BerlinClock.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BDD\BerlinClockFeatureSteps.cs" />
<Compile Include="Classes\IProcessTime.cs" />
<Compile Include="Classes\ProcessTime.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="BDD\BerlinClockFeatureSteps.feature.cs">
<AutoGen>True</AutoGen>
Expand Down
15 changes: 15 additions & 0 deletions Classes/IProcessTime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BerlinClock
{
interface IProcessTime
{
string processSeconds(string seconds);
string processHours(string hours);
string processMinutes(string minutes);
}
}
98 changes: 98 additions & 0 deletions Classes/ProcessTime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BerlinClock
{
class ProcessTime : IProcessTime
{
public string processHours(string hours)
{
string output = "";
int iHours = Convert.ToInt16(hours);
int firstRow = iHours / 5; // No of Lamps to ON in first row
int secondRow = iHours % 5; // No of Lamps to ON in second row

//Put 'R' for every ON a Red Lamp
for(int i=0; i<firstRow; i++)
{
output += "R";
}

//Put 'O' for OFF for remaining Lamps in first row
for(int i=firstRow; i<4; i++)
{
output += "O";
}

output += "\r\n";

//Put 'R' for every ON a Red Lamp in second row
for (int i=0; i<secondRow; i++)
{
output += "R";
}

//Put 'O' for OFF for remaining Lamps in second row
for (int i =secondRow; i<4; i++)
{
output += "O";
}

return output;
}

public string processMinutes(string minutes)
{
string output = "";
int iMinutes = Convert.ToInt16(minutes);
int firstRow = iMinutes / 5; // No of Lamps to ON in first row
int secondRow = iMinutes % 5; // No of Lamps to ON in second row

// Put 'R' for every ON Red lamp and 'Y' for every ON Yellow lamp
for (int i = 0; i < firstRow; i++)
{
if (i == 2 || i == 5 || i == 8) // 3rd, 6th and 9th Lamp are Red
{
output += "R";
}
else
output += "Y";
}

//Put 'O' as OFF for remaining lamps in first row.
for (int i = firstRow; i < 11; i++)
{
output += "O";
}

output += "\r\n";

//Put 'Y' for every ON Yellow lamp in second row
for (int i=0; i<secondRow; i++)
{
output += "Y";
}

//Put 'O' as OFF for remaining lamps in second row.
for (int i=secondRow; i<4; i++)
{
output += "O";
}

return output;
}

public string processSeconds(string seconds)
{
int iSeconds = Convert.ToInt16(seconds);
// Seconds lamp is on/Off every 2 seconds. For every even second it is ON, for every odd second it is OFF.
if (iSeconds % 2 == 0)
return "Y"; //Seconds lamp is yellow in color
else
return "O";
}
}
}
8 changes: 7 additions & 1 deletion Classes/TimeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ public class TimeConverter : ITimeConverter
{
public string convertTime(string aTime)
{
throw new NotImplementedException();
//Split original time string to separate hours, minutes and seconds
string[] splits = aTime.Split(new char[] { ':' });

ProcessTime obj = new ProcessTime();

//Berlin Clock Time will be formed by concatination of processed seconds, hours and minutes strings with nextline char in between.
return obj.processSeconds(splits[2]) + "\r\n" + obj.processHours(splits[0]) + "\r\n" + obj.processMinutes(splits[1]);
}
}
}
Binary file added bin/Debug/BerlinClock.dll
Binary file not shown.
12 changes: 12 additions & 0 deletions bin/Debug/BerlinClock.dll.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<specFlow>
<unitTestProvider name="MsTest" />
<!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config --></specFlow>
</configuration>
Binary file added bin/Debug/BerlinClock.pdb
Binary file not shown.
Binary file not shown.
Binary file added bin/Debug/TechTalk.SpecFlow.dll
Binary file not shown.
8 changes: 8 additions & 0 deletions obj/Debug/BerlinClock.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
C:\MyProjects\DotNetBerlinClock-master\obj\Debug\BerlinClock.csprojResolveAssemblyReference.cache
C:\MyProjects\DotNetBerlinClock-master\bin\Debug\BerlinClock.dll.config
C:\MyProjects\DotNetBerlinClock-master\bin\Debug\BerlinClock.dll
C:\MyProjects\DotNetBerlinClock-master\bin\Debug\BerlinClock.pdb
C:\MyProjects\DotNetBerlinClock-master\bin\Debug\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
C:\MyProjects\DotNetBerlinClock-master\bin\Debug\TechTalk.SpecFlow.dll
C:\MyProjects\DotNetBerlinClock-master\obj\Debug\BerlinClock.dll
C:\MyProjects\DotNetBerlinClock-master\obj\Debug\BerlinClock.pdb
Binary file not shown.
Binary file added obj/Debug/BerlinClock.dll
Binary file not shown.
Binary file added obj/Debug/BerlinClock.pdb
Binary file not shown.
Binary file not shown.
Empty file.
Empty file.
Empty file.
Binary file added packages/SpecFlow.1.9.0/.signature.p7s
Binary file not shown.
31 changes: 31 additions & 0 deletions packages/SpecFlow.1.9.0/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
SpecFlow Licence (New BSD License)

Copyright (c) 2009, TechTalk

Disclaimer:
* The initial codebase of Specflow was written by TechTalk employees.
No 3rd party code was included.
* No code of customer projects was used to create this project.
* TechTalk had the full rights to publish the initial codebase.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the SpecFlow project nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL TECHTALK OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Binary file added packages/SpecFlow.1.9.0/SpecFlow.1.9.0.nupkg
Binary file not shown.
Loading