Compare commits
2
Commits
aa35d4a0f9
...
27747a3b96
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27747a3b96
|
||
|
|
07afbb1486
|
+49
-18
@@ -9,6 +9,7 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks.Dataflow;
|
||||
|
||||
class PI114
|
||||
@@ -18,10 +19,14 @@ class PI114
|
||||
Console.WriteLine("┌───────────────────────────────────────────────┐");
|
||||
Console.WriteLine("\n cc");
|
||||
Console.WriteLine("└───────────────────────────────────────────────┘");
|
||||
programeDictionnary();
|
||||
IDictionary<string, string> specialcharacterDictionnary = programeDictionnary();
|
||||
IDictionary<string, string> letterToMorse = programmeLetterToMorseCode();
|
||||
string[] userTextArray = askUserSentence();
|
||||
verifyUserSentence(userTextArray, specialcharacterDictionnary);
|
||||
translateUserSentenceToMorse(userTextArray, letterToMorse);
|
||||
}
|
||||
|
||||
static void programeDictionnary(){
|
||||
static IDictionary<string, string> programeDictionnary(){
|
||||
|
||||
Dictionary<string,string> specialCharacterDictionnary = new Dictionary<string, string>();
|
||||
specialCharacterDictionnary.Add("é","e");
|
||||
@@ -45,13 +50,7 @@ class PI114
|
||||
specialCharacterDictionnary.Add("â","a");
|
||||
specialCharacterDictionnary.Add("ä","a");
|
||||
specialCharacterDictionnary.Add("ç","c");
|
||||
|
||||
foreach (var ele in specialCharacterDictionnary)
|
||||
{
|
||||
Console.WriteLine($"Key: {ele.Key}, Value: {ele.Value}");
|
||||
}
|
||||
IDictionary<string, string> letterToMorse = programmeLetterToMorseCode();
|
||||
askUserSentence(letterToMorse);
|
||||
return specialCharacterDictionnary;
|
||||
}
|
||||
public static IDictionary<string,string> programmeLetterToMorseCode()
|
||||
{
|
||||
@@ -94,19 +93,52 @@ class PI114
|
||||
letterToMorse.Add(" ", "/");
|
||||
return letterToMorse;
|
||||
}
|
||||
static void askUserSentence(IDictionary<string, string> letterToMorse)
|
||||
static string[] askUserSentence()
|
||||
{
|
||||
Console.Write("Entrez votre phrase à déchiffrer : ");
|
||||
string userText = Console.ReadLine();
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(userText);
|
||||
userTextToAnArray(userText, letterToMorse);
|
||||
string[] userTextArray = userTextToAnArray(userText);
|
||||
return userTextArray;
|
||||
}
|
||||
|
||||
static void userTextToAnArray(string userText, IDictionary<string, string> letterToMorse)
|
||||
static string[] userTextToAnArray(string userText)
|
||||
{
|
||||
string[] userTextArray = userText.Select(x => x.ToString()).ToArray();
|
||||
translateUserSentenceToMorse(userTextArray, letterToMorse);
|
||||
Console.WriteLine(string.Join("", userTextArray));
|
||||
return userTextArray;
|
||||
}
|
||||
static string[] verifyUserSentence(string[] userTextArray, IDictionary<string, string> specialcharacterDictionnary)
|
||||
{
|
||||
int i = 0;
|
||||
foreach( KeyValuePair<string, string> v in specialcharacterDictionnary)
|
||||
{
|
||||
foreach( string k in userTextArray )
|
||||
{
|
||||
if (v.Key.Equals(k))
|
||||
{
|
||||
userTextArray[i] = v.Value;
|
||||
Console.WriteLine("Character : {0} Modifié en {1}", k, userTextArray[i]);
|
||||
}
|
||||
// else if ()
|
||||
// {
|
||||
|
||||
// } à faire character accepté
|
||||
|
||||
// else if (!v.Key.Contains(k))
|
||||
// {
|
||||
// while (!v.Key.Contains(k))
|
||||
// {
|
||||
// Console.WriteLine("Veuillez entrer votre phrase sans charactère spéciale");
|
||||
// string newText = Console.ReadLine();
|
||||
// userTextArray = userTextToAnArray(newText);
|
||||
// }
|
||||
// continue;
|
||||
// } à mettre en else
|
||||
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return userTextArray;
|
||||
}
|
||||
static void translateUserSentenceToMorse(string[] userTextArray, IDictionary<string, string> letterToMorse)
|
||||
{
|
||||
@@ -122,7 +154,7 @@ class PI114
|
||||
var resultCount = v.Value.Count(x => x.ToString() == ".");
|
||||
for (int i = 0 ; i < resultCount; i++)
|
||||
{
|
||||
Console.Beep(1000, 200);
|
||||
Console.Beep(1000, 100);
|
||||
}
|
||||
}
|
||||
else if (v.Value.Contains("-"))
|
||||
@@ -130,7 +162,7 @@ class PI114
|
||||
var resultCount = v.Value.Count(x => x.ToString() == "-");
|
||||
for (int i = 0 ; i < resultCount; i++)
|
||||
{
|
||||
Console.Beep(1000, 200);
|
||||
Console.Beep(1000, 400);
|
||||
}
|
||||
}
|
||||
Console.Write(v.Value + " ");
|
||||
@@ -138,5 +170,4 @@ class PI114
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user