コード例 #1
0
        public static bool AwaitConfirmation()
        {
            List <string> OKStrings = new List <string>()
            {
                "Yes",
                "Ok",
                "OK",
                "taip"
            };
            List <string> NOStrings = new List <string>()
            {
                "No",
                "NO",
                "Ne",
                "Never"
            };
            bool   receivedResult = false;
            bool   resultValue    = false;
            string result         = "";
            bool   firstRead      = true;

            while (!receivedResult)
            {
                if (!firstRead)
                {
                    FancyWriter.WriteSlow("I did not get that... Please repeat that.");
                }
                var inString = Console.ReadLine();
                var words    = inString.Split(" ");
                foreach (var word in words)
                {
                    if (OKStrings.Contains(word))

                    {
                        receivedResult = true;
                        result         = word;
                        resultValue    = true;
                        FancyWriter.WriteSlow("Ok is ok. Proceding...");
                        break;
                    }
                    if (NOStrings.Contains(word))
                    {
                        receivedResult = true;
                        result         = word;
                        resultValue    = false;
                        FancyWriter.WriteSlow("It's treason then!");
                    }
                }
                firstRead = false;
            }

            return(resultValue);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            FancyWriter.WriteSlow("Hello World!");
            FancyWriter.WriteSlow("My name is Terminal Tree. I am here to guide you to do various tasks and decisions.");
            FancyWriter.WriteSlow("Do you want to continue?");
            if (FancyReader.AwaitConfirmation())
            {
                FancyWriter.WriteSlow("What shall we do?");
                FancyWriter.WriteSlow("We shall " + FancyReader.AwaitResponse());
            }



            Console.ReadKey();
        }