Exemplo n.º 1
0
 protected Question(string input, Knowledge<T> knowledge)
 {
     Input = input;
     Knowledge = knowledge;
     Information = new Information<T>();
     MakeInfo();
 }
Exemplo n.º 2
0
        public string Unit;   // == Credits

        public virtual void MakeInfo(string input, Knowledge <T> knowledge)
        {
            var splitted = input.Split(' ');

            // Assumption : string input contains single spaces
            try
            {
                int i;
                for (i = 0;
                     i < splitted.Count() &&
                     knowledge.ForeignLanguageToKnownLanguageDictionary.ContainsKey(splitted[i]);
                     ++i)
                {
                    Number += knowledge.ForeignLanguageToKnownLanguageDictionary[splitted[i]];
                }

                // by now, Number contains only the roman numerals
                Item = splitted[i];

                // Assumption : next word is "is"
                // incrementing i twice thusly to reach Value
                i    += 2;
                Value = int.Parse(splitted[i]);

                // Assumption : Unit is single word
                ++i;
                Unit = splitted[i];
            }
            catch (IndexOutOfRangeException ioore)
            {
                Console.WriteLine("Data is not provided as agreed upon specification.");
                Console.WriteLine("Message : " + ioore.Message);
            }
        }
Exemplo n.º 3
0
            public static Question <T> GenerateQuestion(string input, Knowledge <T> knowledge)
            {
                var smallLetteredInput = input.ToLower();

                if (smallLetteredInput.Contains(" much "))
                {
                    return(new MuchTypeQuestion <T>(input, knowledge));
                }
                if (smallLetteredInput.Contains(" many "))
                {
                    return(new ManyTypeQuestion <T>(input, knowledge));
                }
                throw new NotAQuestionException(string.Empty, new ArgumentException().ToString());
            }
Exemplo n.º 4
0
 public MuchTypeQuestion(string input, Knowledge <T> knowledge)
     : base(input, knowledge)
 {
 }