Skip to content

Commit b3c35d4

Browse files
committedMay 15, 2017
Added functionality to identify unidentified seeds.
1 parent bcaa614 commit b3c35d4

8 files changed

+144
-0
lines changed
 

‎farming-system.sln

+18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,25 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
44
VisualStudioVersion = 15.0.26430.6
55
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Systems.Farming", "src\Systems.Farming\Systems.Farming.csproj", "{C0D3AC42-CDB2-406D-B103-4D135C85683E}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Systems.Farming.Tests", "tests\Systems.Farming.Tests\Systems.Farming.Tests.csproj", "{BB20701E-5FC9-4FF5-BCDB-FD61C0F3CE01}"
9+
EndProject
610
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{C0D3AC42-CDB2-406D-B103-4D135C85683E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{C0D3AC42-CDB2-406D-B103-4D135C85683E}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{C0D3AC42-CDB2-406D-B103-4D135C85683E}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{C0D3AC42-CDB2-406D-B103-4D135C85683E}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{BB20701E-5FC9-4FF5-BCDB-FD61C0F3CE01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{BB20701E-5FC9-4FF5-BCDB-FD61C0F3CE01}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{BB20701E-5FC9-4FF5-BCDB-FD61C0F3CE01}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{BB20701E-5FC9-4FF5-BCDB-FD61C0F3CE01}.Release|Any CPU.Build.0 = Release|Any CPU
24+
EndGlobalSection
725
GlobalSection(SolutionProperties) = preSolution
826
HideSolutionNode = FALSE
927
EndGlobalSection

‎src/Systems.Farming/ISeed.cs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Systems.Farming
6+
{
7+
public interface ISeed
8+
{
9+
string SeedType { get; }
10+
}
11+
}

‎src/Systems.Farming/IdentifiedSeed.cs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Systems.Farming
6+
{
7+
public class IdentifiedSeed : ISeed
8+
{
9+
public IdentifiedSeed(string seedType)
10+
{
11+
SeedType = seedType;
12+
}
13+
14+
public string SeedType { get; private set; }
15+
}
16+
}

‎src/Systems.Farming/SeedBank.cs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Systems.Farming
6+
{
7+
public class SeedBank
8+
{
9+
public IList<ISeed> _seeds = new List<ISeed>();
10+
11+
public SeedBank()
12+
{
13+
14+
}
15+
16+
public void Add(string seedType)
17+
{
18+
_seeds.Add(new IdentifiedSeed(seedType));
19+
}
20+
21+
public ISeed Identify(ISeed seed)
22+
{
23+
if (seed is IdentifiedSeed) return seed;
24+
25+
Random random = new Random();
26+
return _seeds[random.Next(_seeds.Count) - 1];
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard1.4</TargetFramework>
5+
</PropertyGroup>
6+
7+
</Project>
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Systems.Farming
6+
{
7+
public class UnidentifiedSeed : ISeed
8+
{
9+
public UnidentifiedSeed()
10+
{
11+
SeedType = "Unidentified Seed";
12+
}
13+
14+
public string SeedType { get; private set; }
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Text;
5+
using Xunit;
6+
7+
namespace Systems.Farming.Tests
8+
{
9+
public class IdentificationProcedure
10+
{
11+
[Fact]
12+
public void IdentifySeed()
13+
{
14+
SeedBank seedBank = new SeedBank();
15+
seedBank.Add("Carrot");
16+
seedBank.Add("Dragonfruit");
17+
seedBank.Add("Squash");
18+
19+
ISeed seed = new UnidentifiedSeed();
20+
ISeed idenitifiedSeed = seedBank.Identify(seed);
21+
22+
Assert.NotEqual(idenitifiedSeed?.GetType(), typeof(UnidentifiedSeed));
23+
Debug.WriteLine($"Identified Seed Type: {idenitifiedSeed.SeedType}");
24+
}
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp1.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
9+
<PackageReference Include="xunit" Version="2.2.0" />
10+
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\..\src\Systems.Farming\Systems.Farming.csproj" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
19+
</ItemGroup>
20+
21+
</Project>

0 commit comments

Comments
 (0)
Please sign in to comment.