Beispiel #1
0
        private static void AddWithChildrenColored(IAnswer response, List <ConsoleOutput> returnValue)
        {
            foreach (var type in MasterColors.Keys)
            {
                if (type.IsAssignableFrom(response.GetType()))
                {
                    returnValue.Add(new ConsoleOutput(MasterColors[type], response.Text + " "));
                    break;
                }
            }

            if (response.Children != null)
            {
                foreach (var child in response.Children)
                {
                    foreach (var type in ChildColors.Keys)
                    {
                        if (type.IsAssignableFrom(child.GetType()))
                        {
                            returnValue.Add(new ConsoleOutput(ChildColors[type], child.Text + " "));
                            break;
                        }
                    }
                }
            }
        }
        public bool CheckAnswer(IAnswer answer)
        {
            if (answer == null)
                throw new ArgumentNullException("answer", "answer is null.");
            if (answer.GetType() != typeof(TextAnswer))
                throw new InvalidOperationException("Exact text answer required.");

            return CheckAnswer((TextAnswer)answer);
        }
        public bool CheckAnswer(IAnswer answer)
        {
            if (answer == null)
            {
                throw new ArgumentNullException("answer", "answer is null.");
            }
            if (answer.GetType() != typeof(TextAnswer))
            {
                throw new InvalidOperationException("Exact text answer required.");
            }

            return(CheckAnswer((TextAnswer)answer));
        }
Beispiel #4
0
 public static void ShowCorrectAnswers(IQuestion question, IAnswer answer)
 {
     CheckedAnswersHandler[answer.GetType()](question, answer);
 }