diff --git a/MorseCodeTranslateToEnglish.sln b/MorseCodeTranslateToEnglish.sln new file mode 100644 index 0000000..61550dd --- /dev/null +++ b/MorseCodeTranslateToEnglish.sln @@ -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 diff --git a/MorseCodeTranslateToEnglish/App.config b/MorseCodeTranslateToEnglish/App.config new file mode 100644 index 0000000..00bfd11 --- /dev/null +++ b/MorseCodeTranslateToEnglish/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/MorseCodeTranslateToEnglish/MorseCodeTranslateToEnglish.csproj b/MorseCodeTranslateToEnglish/MorseCodeTranslateToEnglish.csproj new file mode 100644 index 0000000..d1a61f0 --- /dev/null +++ b/MorseCodeTranslateToEnglish/MorseCodeTranslateToEnglish.csproj @@ -0,0 +1,52 @@ + + + + + Debug + AnyCPU + {9A5D7A96-898D-402B-B3A2-11DC57C2AB17} + Exe + MorseCodeTranslateToEnglish + MorseCodeTranslateToEnglish + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MorseCodeTranslateToEnglish/Program.cs b/MorseCodeTranslateToEnglish/Program.cs new file mode 100644 index 0000000..a8e19db --- /dev/null +++ b/MorseCodeTranslateToEnglish/Program.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + + +namespace MorseCodeTranslateToEnglish +{ + class Program + { + + static Dictionary morse; + + static void Main(string[] args) + { + InitialiseDictionary(); + readFromFile(); + } + + private static void InitialiseDictionary() + { + morse = new Dictionary() //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(); + } + } +} diff --git a/MorseCodeTranslateToEnglish/Properties/AssemblyInfo.cs b/MorseCodeTranslateToEnglish/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..237e36d --- /dev/null +++ b/MorseCodeTranslateToEnglish/Properties/AssemblyInfo.cs @@ -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")] diff --git a/MorseCodeTranslateToEnglish/bin/Debug/MorseCodeTranslateToEnglish.exe b/MorseCodeTranslateToEnglish/bin/Debug/MorseCodeTranslateToEnglish.exe new file mode 100644 index 0000000..5065cfc Binary files /dev/null and b/MorseCodeTranslateToEnglish/bin/Debug/MorseCodeTranslateToEnglish.exe differ diff --git a/MorseCodeTranslateToEnglish/bin/Debug/MorseCodeTranslateToEnglish.exe.config b/MorseCodeTranslateToEnglish/bin/Debug/MorseCodeTranslateToEnglish.exe.config new file mode 100644 index 0000000..00bfd11 --- /dev/null +++ b/MorseCodeTranslateToEnglish/bin/Debug/MorseCodeTranslateToEnglish.exe.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/MorseCodeTranslateToEnglish/bin/Debug/MorseCodeTranslateToEnglish.pdb b/MorseCodeTranslateToEnglish/bin/Debug/MorseCodeTranslateToEnglish.pdb new file mode 100644 index 0000000..90536a6 Binary files /dev/null and b/MorseCodeTranslateToEnglish/bin/Debug/MorseCodeTranslateToEnglish.pdb differ diff --git a/MorseCodeTranslateToEnglish/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/MorseCodeTranslateToEnglish/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 0000000..2ddd585 Binary files /dev/null and b/MorseCodeTranslateToEnglish/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.csproj.CoreCompileInputs.cache b/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..e54b871 --- /dev/null +++ b/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +43facce401dc19697cf34b49c184fb2ce77f92b1 diff --git a/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.csproj.FileListAbsolute.txt b/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..f78f871 --- /dev/null +++ b/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.csproj.FileListAbsolute.txt @@ -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 diff --git a/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.csprojResolveAssemblyReference.cache b/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.csprojResolveAssemblyReference.cache new file mode 100644 index 0000000..bcf462d Binary files /dev/null and b/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.csprojResolveAssemblyReference.cache differ diff --git a/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.exe b/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.exe new file mode 100644 index 0000000..5065cfc Binary files /dev/null and b/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.exe differ diff --git a/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.pdb b/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.pdb new file mode 100644 index 0000000..90536a6 Binary files /dev/null and b/MorseCodeTranslateToEnglish/obj/Debug/MorseCodeTranslateToEnglish.pdb differ