예제 #1
0
        public static void Main()
        {
            while (true)
            {
                Console.WriteLine("Welcome to the Morse Code Translator");
                Console.Write("Enter text to translate or press ENTER to exit: ");
                string input = Console.ReadLine().Trim();

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

                string output;

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

                Console.WriteLine(output);
            }
        }
        public static void Main()
        {
            while (true)
            {
                Console.Write(": ");
                string input = Console.ReadLine().Trim();

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

                string output;

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

                Console.WriteLine(output);
            }
        }
예제 #3
0
        public static void Main()
        {
            while (true)
            {
                Console.Write(": ");
                string input = Console.ReadLine();

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

                string output = MorseCodeTranslator.ToMorse(input);
                Console.WriteLine(output);
            }
        }
예제 #4
0
        static void Main()
        {
            // HASHSET EXAMPLE
            List <Student> students = new List <Student>
            {
                new Student()
                {
                    Name = "Sally", GradeLevel = 3
                },
                new Student()
                {
                    Name = "Bob", GradeLevel = 3
                },
                new Student()
                {
                    Name = "Sally", GradeLevel = 2
                }
            };

            SchoolRoll schoolRoll = new SchoolRoll();

            schoolRoll.AddStudents(students);

            schoolRoll.AddStudents(students);

            foreach (Student student in schoolRoll.Students)
            {
                Console.WriteLine($"{student.Name} is in grade {student.GradeLevel}");
            }

            // DICTIONARY EXAMPLE
            while (true)
            {
                Console.Write(": ");
                string input = Console.ReadLine();

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

                string output = MorseCodeTranslator.ToMorse(input);

                Console.WriteLine(output);
            }
        }