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
142 changes: 0 additions & 142 deletions BDD/BerlinClockFeatureSteps.feature.cs

This file was deleted.

23 changes: 13 additions & 10 deletions BerlinClock.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -49,23 +52,23 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BDD\BerlinClockFeatureSteps.cs" />
<Compile Include="Classes\LevelsFactory.cs" />
<Compile Include="Classes\StatesColors.cs" />
<Compile Include="Enums\LevesEnum.cs" />
<Compile Include="Model\Levels\IBerlinClockLevel.cs" />
<Compile Include="Model\Levels\HourFirstLevel.cs" />
<Compile Include="Model\Levels\HourSecondLevel.cs" />
<Compile Include="Model\Levels\LevelBase.cs" />
<Compile Include="Model\Levels\MinutesFirstLevel.cs" />
<Compile Include="Model\Levels\MinutesSecondLevel.cs" />
<Compile Include="Model\Levels\FirstLevel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="BDD\BerlinClockFeatureSteps.feature.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>BerlinClockFeatureSteps.feature</DependentUpon>
</Compile>
<Compile Include="Classes\ITimeConverter.cs" />
<Compile Include="Classes\TimeConverter.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="BDD\BerlinClockFeatureSteps.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>BerlinClockFeatureSteps.feature.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
Expand Down
19 changes: 17 additions & 2 deletions BerlinClock.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
# Visual Studio 15
VisualStudioVersion = 15.0.28307.102
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BerlinClock", "BerlinClock.csproj", "{0451204D-BF86-43E1-B560-FC9AC830B9A9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTestProject1", "XUnitTestProject1\XUnitTestProject1.csproj", "{F4BC5FB1-CE92-4B5E-934A-328913E1DD87}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpectFlowTest", "SpectFlowTest\SpectFlowTest.csproj", "{E93FC768-1722-4176-B26E-929A91707C31}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,8 +19,19 @@ Global
{0451204D-BF86-43E1-B560-FC9AC830B9A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0451204D-BF86-43E1-B560-FC9AC830B9A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0451204D-BF86-43E1-B560-FC9AC830B9A9}.Release|Any CPU.Build.0 = Release|Any CPU
{F4BC5FB1-CE92-4B5E-934A-328913E1DD87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4BC5FB1-CE92-4B5E-934A-328913E1DD87}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4BC5FB1-CE92-4B5E-934A-328913E1DD87}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4BC5FB1-CE92-4B5E-934A-328913E1DD87}.Release|Any CPU.Build.0 = Release|Any CPU
{E93FC768-1722-4176-B26E-929A91707C31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E93FC768-1722-4176-B26E-929A91707C31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E93FC768-1722-4176-B26E-929A91707C31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E93FC768-1722-4176-B26E-929A91707C31}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {84812F61-B50B-45FB-8C7B-F183CDD3D315}
EndGlobalSection
EndGlobal
32 changes: 32 additions & 0 deletions Classes/LevelsFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using BerlinClock.Enums;
using BerlinClock.Model.Levels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BerlinClock.Classes
{
public static class LevelsFactory
{
public static IBerlinClockLevel GetLevel(LevesEnum type)
{
switch(type)
{
case LevesEnum.First:
return new FirstLevel();
case LevesEnum.FirstHour:
return new HourFirstLevel();
case LevesEnum.SecondHour:
return new HourSecondLevel();
case LevesEnum.FirstMinute:
return new MinutesFirstLevel();
case LevesEnum.SecondMinute:
return new MinutesSecondLevel();
default:
throw new KeyNotFoundException();
}
}
}
}
15 changes: 15 additions & 0 deletions Classes/StatesColors.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.Classes
{
public class StatesColors
{
public const char RED = 'R';
public const char YELLOW = 'Y';
public const char NONE = 'O';
}
}
47 changes: 45 additions & 2 deletions Classes/TimeConverter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using BerlinClock.Classes;
using BerlinClock.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -9,7 +11,48 @@ public class TimeConverter : ITimeConverter
{
public string convertTime(string aTime)
{
throw new NotImplementedException();
var (hours, minutes, seconds) = SplitTime(aTime);
string resultClock = string.Empty;
foreach (var level in (LevesEnum[])Enum.GetValues(typeof(LevesEnum)))
{
resultClock += $"{LevelsFactory.GetLevel(level).ParseTime(hours, minutes, seconds)}";
}
return resultClock;
}

private (int, int, int) SplitTime(string time)
{
int hours = 0;
int minutes = 0;
int seconds = 0;

var list = time.Split(':');
if(list.Count() > 3)
{
throw new ArgumentException();
}
if (list.Count() >= 1)
{
if (!int.TryParse(list[0], out hours))
{
throw new ArgumentException();
}
}
if (list.Count() >= 2)
{
if (!int.TryParse(list[1], out minutes))
{
throw new ArgumentException();
}
}
if (list.Count() == 3)
{
if (!int.TryParse(list[2], out seconds))
{
throw new ArgumentException();
}
}
return (hours, minutes, seconds);
}
}
}
17 changes: 17 additions & 0 deletions Enums/LevesEnum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BerlinClock.Enums
{
public enum LevesEnum
{
First,
FirstHour,
SecondHour,
FirstMinute,
SecondMinute
}
}
23 changes: 23 additions & 0 deletions Model/Levels/FirstLevel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using BerlinClock.Classes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BerlinClock.Model.Levels
{
public class FirstLevel : LevelBase
{
public FirstLevel()
:base(1)
{

}
public override string ParseTime(int hours, int minutes, int seconds)
{
base.CheckSeconds(seconds);
return seconds % 2 > 0 ? StatesColors.NONE.ToString() + Environment.NewLine : StatesColors.YELLOW.ToString() + Environment.NewLine;
}
}
}
Loading