feat(program): add morse code dictionary and refactor main into separate methods
Extract dictionary initialization into programeDictionnary() method and add programmeLetterToMorseCode() method with complete morse code mappings for letters a-z and digits 0-9. Add program header display in Main() and call to askUserSentence() to facilitate user interaction flow.
This commit is contained in:
1 file changed
+49
-1
+49
-1
@@ -11,9 +11,16 @@ using System;
|
|||||||
|
|
||||||
class PI114
|
class PI114
|
||||||
{
|
{
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("┌───────────────────────────────────────────────┐");
|
||||||
|
Console.WriteLine("\n cc");
|
||||||
|
Console.WriteLine("└───────────────────────────────────────────────┘");
|
||||||
|
programeDictionnary();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void programeDictionnary(){
|
||||||
|
|
||||||
Dictionary<string,string> specialCharacterDictionnary = new Dictionary<string, string>();
|
Dictionary<string,string> specialCharacterDictionnary = new Dictionary<string, string>();
|
||||||
specialCharacterDictionnary.Add("é","e");
|
specialCharacterDictionnary.Add("é","e");
|
||||||
specialCharacterDictionnary.Add("è","e");
|
specialCharacterDictionnary.Add("è","e");
|
||||||
@@ -41,5 +48,46 @@ class PI114
|
|||||||
{
|
{
|
||||||
Console.WriteLine($"Key: {ele.Key}, Value: {ele.Value}");
|
Console.WriteLine($"Key: {ele.Key}, Value: {ele.Value}");
|
||||||
}
|
}
|
||||||
|
askUserSentence();
|
||||||
|
}
|
||||||
|
static void programmeLetterToMorseCode()
|
||||||
|
{
|
||||||
|
Dictionary<string, string> letterToMorse = new Dictionary<string, string>();
|
||||||
|
letterToMorse.Add("a", ".-");
|
||||||
|
letterToMorse.Add("b", "-...");
|
||||||
|
letterToMorse.Add("c", "-.-.");
|
||||||
|
letterToMorse.Add("d", "-..");
|
||||||
|
letterToMorse.Add("e", ".");
|
||||||
|
letterToMorse.Add("f", "..-.");
|
||||||
|
letterToMorse.Add("g", "--.");
|
||||||
|
letterToMorse.Add("h", "....");
|
||||||
|
letterToMorse.Add("i", "..");
|
||||||
|
letterToMorse.Add("j", ".---");
|
||||||
|
letterToMorse.Add("k", "-.-");
|
||||||
|
letterToMorse.Add("l", ".-..");
|
||||||
|
letterToMorse.Add("m", "--");
|
||||||
|
letterToMorse.Add("n", "-.");
|
||||||
|
letterToMorse.Add("o", "---");
|
||||||
|
letterToMorse.Add("p", ".--.");
|
||||||
|
letterToMorse.Add("q", "--.-");
|
||||||
|
letterToMorse.Add("r", ".-.");
|
||||||
|
letterToMorse.Add("s", "...");
|
||||||
|
letterToMorse.Add("t", "-");
|
||||||
|
letterToMorse.Add("u", "..-");
|
||||||
|
letterToMorse.Add("v", "...-");
|
||||||
|
letterToMorse.Add("w", ".--");
|
||||||
|
letterToMorse.Add("x", "-..-");
|
||||||
|
letterToMorse.Add("y", "-.--");
|
||||||
|
letterToMorse.Add("z", "--..");
|
||||||
|
letterToMorse.Add("1", "-----");
|
||||||
|
letterToMorse.Add("2", ".----");
|
||||||
|
letterToMorse.Add("3", "..---");
|
||||||
|
letterToMorse.Add("4", "...--");
|
||||||
|
letterToMorse.Add("5", "....-");
|
||||||
|
letterToMorse.Add("6", "-....");
|
||||||
|
letterToMorse.Add("7", "--...");
|
||||||
|
letterToMorse.Add("8", "---..");
|
||||||
|
letterToMorse.Add("9", "----.");
|
||||||
|
letterToMorse.Add(" ", "/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user