Exemple #1
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.Write(": ");
                string input = Console.ReadLine();

                if (string.IsNullOrWhiteSpace(input))
                {
                    break;
                }

                string output;

                if (input[0] == '.' || input[0] == '-')
                {
                    output = MorseCodeTranslator.ToText(input);
                }
                else
                {
                    output = MorseCodeTranslator.ToMorse(input);
                }

                Console.WriteLine(output);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.Write("Text to translate (or Enter to quit): ");
                string textInput = Console.ReadLine();

                if (string.IsNullOrWhiteSpace(textInput))
                {
                    break;
                }

                string morseOutput = MorseCodeTranslator.ToMorse(textInput);
                Console.WriteLine(morseOutput);
            }

            while (true)
            {
                Console.Write("Morse to translate (or Enter to quit): ");
                string morseInput = Console.ReadLine();

                if (string.IsNullOrWhiteSpace(morseInput))
                {
                    break;
                }

                string textOutput = MorseCodeTranslator.ToText(morseInput);
                Console.WriteLine(textOutput);
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("Enter 1 to morse, enter 2 to demorse");
                string option = Console.ReadLine();

                if (option == "1")
                {
                    Console.Write(":");
                    string input = Console.ReadLine();
                    if (string.IsNullOrWhiteSpace(input))
                    {
                        break;
                    }
                    string output = MorseCodeTranslator.ToMorse(input);
                    Console.WriteLine(output);
                }
                else if (option == "2")
                {
                    Console.Write(":");
                    string input = Console.ReadLine();
                    if (string.IsNullOrWhiteSpace(input))
                    {
                        break;
                    }
                    string output = MorseCodeTranslator.DeMorse(input);
                    Console.WriteLine(output);
                }
            }
        }
        static void TextToMorse()
        {
            Console.Clear();
            Console.Write("Enter morse code to translate: ");
            string input = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(input))
            {
                return;
            }
            string output = MorseCodeTranslator.ToMorse(input);

            Console.WriteLine(output);
            Console.WriteLine();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.Write("String to translate to Morse Code (enter nothing to quit): ");
                string input = Console.ReadLine();

                if (string.IsNullOrWhiteSpace(input))
                {
                    break;
                }

                Console.WriteLine("Morse Code: " + MorseCodeTranslator.ToMorse(input));
            }
        }
Exemple #6
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.Write(": ");
                string input = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(input))
                {
                    break;
                }
                string output = MorseCodeTranslator.ToMorse(input);
                Console.WriteLine(output);

                Console.Write("Provide a morse message for translation: ");
                input = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(input))
                {
                    break;
                }
                output = MorseCodeTranslator.ToText(input);
                Console.WriteLine(output);
            }
        }