Exemple #1
0
    public static void StartMorse()
    {
        bool exitStr = true;

        while (exitStr)
        {
            try
            {
                ClassMessDisplay.MorseScreen();
                string choise = Console.ReadLine();
                if (GeneralCipherClass.SelectEnterForExit(choise))
                {
                    break;
                }
                int          number = int.Parse(choise);
                Morse_Cipher morseCode;
                if (number <= 3 & number >= 1)
                {
                    switch (number)
                    {
                    case 1:
                        Console.Clear();
                        Console.WriteLine("Enter Word");
                        string val1 = Console.ReadLine();
                        morseCode = new Morse_Cipher(val1);
                        morseCode.crypt(val1);
                        ClassMessDisplay.OutQuestionOfContinueScreen();
                        val1    = Console.ReadLine();
                        exitStr = SelectContinueAct(val1);
                        break;

                    case 2:
                        Console.WriteLine("Enter Word");
                        string val2 = Console.ReadLine();
                        morseCode = new Morse_Cipher(val2);
                        morseCode.decrypt(val2);
                        break;

                    case 3:
                        Console.WriteLine("Enter Word Or Signal");
                        string val3 = Console.ReadLine();
                        morseCode = new Morse_Cipher(val3);
                        morseCode.SoundOfMorse(val3);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Wrong digit entered");
            }
        }
    }
Exemple #2
0
    public static void StartCaesar()
    {
        bool exitStr = true;

        while (exitStr)
        {
            try
            {
                ClassMessDisplay.CaesarScreen();
                string choise = Console.ReadLine();
                if (GeneralCipherClass.SelectEnterForExit(choise))
                {
                    break;
                }
                int         number = int.Parse(choise);
                CesarCipher cesarCode;
                if (number <= 3 & number >= 1)
                {
                    switch (number)
                    {
                    case 1:
                        Console.Clear();
                        Console.WriteLine("Enter a shift number");
                        int shift = Int32.Parse(Console.ReadLine());
                        Console.Clear();
                        Console.WriteLine("Enter Word");
                        string val1 = Console.ReadLine();
                        cesarCode = new CesarCipher(shift);
                        cesarCode.crypt(val1);
                        ClassMessDisplay.OutQuestionOfContinueScreen();
                        val1    = Console.ReadLine();
                        exitStr = SelectContinueAct(val1);
                        break;

                    case 2:
                        Console.Clear();
                        Console.WriteLine("Enter Word");
                        string val2 = Console.ReadLine();
                        cesarCode = new CesarCipher(Int32.Parse(val2));
                        cesarCode.decrypt(val2);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Wrong digit entered");
            }
        }
    }
Exemple #3
0
        private static void MainLoop()
        {
            bool   booleanGame = true;
            string enterString;

            while (booleanGame)
            {
                try
                {
                    ClassMessDisplay.MainScreenForChoise();
                    enterString = Console.ReadLine();
                    //Условие работает только при первом вводе
                    if (enterString == " ")
                    {
                        Environment.Exit(0);
                    }
                    int numCase;
                    if (int.TryParse(enterString, out numCase) & (Int32.Parse(enterString) >= 1 & Int32.Parse(enterString) <= 4))
                    {
                        try
                        {
                            ChoiseCipher choiseCipher = new ChoiseCipher(numCase);
                            choiseCipher = null;
                        }
                        catch (Exception)
                        {
                            booleanGame = false;
                            Console.WriteLine("Wrong digit entered");
                        }
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("Wrong symbol entered");
                }
            }
            Console.ReadKey();
        }
Exemple #4
0
 static void Main(string[] args)
 {
     ClassMessDisplay.HelloMessage();
     MainLoop();
 }