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
31 changes: 31 additions & 0 deletions Hangman/Hangman.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hangman", "Hangman\Hangman.csproj", "{4C13563C-5554-4FDA-801E-C84E259B3761}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HangmanTest", "HangmanTest\HangmanTest.csproj", "{9041AD16-CBA7-44B7-AF91-1095D155BC67}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4C13563C-5554-4FDA-801E-C84E259B3761}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C13563C-5554-4FDA-801E-C84E259B3761}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C13563C-5554-4FDA-801E-C84E259B3761}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C13563C-5554-4FDA-801E-C84E259B3761}.Release|Any CPU.Build.0 = Release|Any CPU
{9041AD16-CBA7-44B7-AF91-1095D155BC67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9041AD16-CBA7-44B7-AF91-1095D155BC67}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9041AD16-CBA7-44B7-AF91-1095D155BC67}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9041AD16-CBA7-44B7-AF91-1095D155BC67}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4E6053DD-C00B-4488-8FC7-A3ADB6176D89}
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions Hangman/Hangman/Hangman.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>
39 changes: 39 additions & 0 deletions Hangman/Hangman/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Text;

namespace HangmanGame
{
public class Hangman
{
private string _secret = "";
private StringBuilder _secredGuessed;
public Hangman(string secret)
{
_secret = secret.ToLower();
var secredGuessed = new string('-', secret.Length);
_secredGuessed = new StringBuilder(secredGuessed);

}
public string Guess(char letter)
{
var lowerLetter = Char.ToLower(letter);
for (int i = 0; i < _secret.Length; i++)
{
if (_secret[i] == lowerLetter)
{
_secredGuessed[i] = lowerLetter;
}
}

return _secredGuessed.ToString();
}
}

class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
19 changes: 19 additions & 0 deletions Hangman/HangmanTest/HangmanTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Hangman\Hangman.csproj" />
</ItemGroup>

</Project>
40 changes: 40 additions & 0 deletions Hangman/HangmanTest/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using HangmanGame;
using NUnit.Framework;

namespace HangmanTest
{
public class Tests
{
[SetUp]
public void Setup()
{
}

[Test]
public void Test1()
{
var h = new Hangman("Test");

var ret = h.Guess('a');

Assert.AreEqual("----", ret);

ret = h.Guess('t');

Assert.AreEqual("t--t", ret);

ret = h.Guess('t');

Assert.AreEqual("t--t", ret);

ret = h.Guess('E');

Assert.AreEqual("te-t", ret);

ret = h.Guess('s');

Assert.AreEqual("test", ret);

}
}
}