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

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2015
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorseCodeTranslateToEnglish", "MorseCodeTranslateToEnglish\MorseCodeTranslateToEnglish.csproj", "{9A5D7A96-898D-402B-B3A2-11DC57C2AB17}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9A5D7A96-898D-402B-B3A2-11DC57C2AB17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A5D7A96-898D-402B-B3A2-11DC57C2AB17}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A5D7A96-898D-402B-B3A2-11DC57C2AB17}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A5D7A96-898D-402B-B3A2-11DC57C2AB17}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EA2B4512-174F-4C1C-97E8-787C05482B46}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions MorseCodeTranslateToEnglish/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
52 changes: 52 additions & 0 deletions MorseCodeTranslateToEnglish/MorseCodeTranslateToEnglish.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9A5D7A96-898D-402B-B3A2-11DC57C2AB17}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>MorseCodeTranslateToEnglish</RootNamespace>
<AssemblyName>MorseCodeTranslateToEnglish</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
96 changes: 96 additions & 0 deletions MorseCodeTranslateToEnglish/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace MorseCodeTranslateToEnglish
{
class Program
{

static Dictionary<string, char> morse;

static void Main(string[] args)
{
InitialiseDictionary();
readFromFile();
}

private static void InitialiseDictionary()
{
morse = new Dictionary<string, char>() //dictionary to translate morse code to characers
{
{".-",'a'},
{"-...",'b'},
{"-.-.",'c'},
{"-..",'d'},
{".",'e'},
{"..-.",'f'},
{"--.",'g'},
{"....",'h'},
{"..",'i'},
{".---",'j'},
{"-.-",'k'},
{".-..",'l'},
{"--",'m'},
{"-.",'n'},
{"---",'o'},
{".--.",'p'},
{"--.-",'q'},
{".-.",'r'},
{"...",'s'},
{"-",'t'},
{"..-",'u'},
{"...-",'v'},
{".--",'w'},
{"-..-",'x'},
{"-.--",'y'},
{"--..",'z' },
{".----",'1'},
{"..---",'2'},
{"...--",'3'},
{"....-",'4'},
{".....",'5'},
{"-....",'6'},
{"--...",'7'},
{"---..",'8'},
{"----.",'9'},
{"-----",'0'},
{"", ' ' }
};
}

public static void readFromFile()
{
try //attempts to access the file C:\Temp\MorrisCodeFile.txt. If the file cannot be accessed, then the user will receive notification of file read failure
{
string input = System.IO.File.ReadAllText(@"C:\Temp\MorrisCodeFile.txt");
input = input.Replace("||", " ").Replace("\r", " \r").Replace("\n", " \n "); //replaces the || delimiter with a space, also a space after carriage return and line feed
Console.WriteLine(translate(input));
Console.WriteLine("Press enter to end.");
Console.ReadKey(false);
}
catch
{
Console.WriteLine("The file doesn't exist. Please check the file location and file name. (C:\\Temp\\MorrisCodeFile.txt)");
Console.WriteLine("Press any key to close.");
Console.ReadKey(false);
}
}

private static string translate(string input)
{

string[] words = input.Split(' '); //separates the morse code into individual words based on single space
StringBuilder sb = new StringBuilder();
foreach (string word in words)
{
if (morse.Keys.Contains(word)) //if the value exists in the dictionary, then it will display the associated character value
sb.Append(morse[word]);
else sb.Append(word); //if the value does not exist, then the value will be used (mainly for troubleshooting purposes)
}
return sb.ToString();
}
}
}
36 changes: 36 additions & 0 deletions MorseCodeTranslateToEnglish/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MorseCodeTranslateToEnglish")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MorseCodeTranslateToEnglish")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9a5d7a96-898d-402b-b3a2-11dc57c2ab17")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
43facce401dc19697cf34b49c184fb2ce77f92b1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
c:\users\todd\source\repos\MorseCodeTranslateToEnglish\MorseCodeTranslateToEnglish\bin\Debug\MorseCodeTranslateToEnglish.exe.config
c:\users\todd\source\repos\MorseCodeTranslateToEnglish\MorseCodeTranslateToEnglish\bin\Debug\MorseCodeTranslateToEnglish.exe
c:\users\todd\source\repos\MorseCodeTranslateToEnglish\MorseCodeTranslateToEnglish\bin\Debug\MorseCodeTranslateToEnglish.pdb
c:\users\todd\source\repos\MorseCodeTranslateToEnglish\MorseCodeTranslateToEnglish\obj\Debug\MorseCodeTranslateToEnglish.csprojResolveAssemblyReference.cache
c:\users\todd\source\repos\MorseCodeTranslateToEnglish\MorseCodeTranslateToEnglish\obj\Debug\MorseCodeTranslateToEnglish.csproj.CoreCompileInputs.cache
c:\users\todd\source\repos\MorseCodeTranslateToEnglish\MorseCodeTranslateToEnglish\obj\Debug\MorseCodeTranslateToEnglish.exe
c:\users\todd\source\repos\MorseCodeTranslateToEnglish\MorseCodeTranslateToEnglish\obj\Debug\MorseCodeTranslateToEnglish.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.