static void Main(string[] args)
        {
            InputProcessor input = new InputProcessor(); // new object of InputProcessor classs

            input.PreventSLetter();
            input.PreventEvenNumbers();
            input.SetResponceTo10CharsOfInput();
            input.Process();
        }
Beispiel #2
0
 public static void SetResponceTo10CharsOfInput(this InputProcessor processor)
 {
     processor.Processors.Add(inputModel =>
     {
         if (inputModel.Input.Length > 10)
         {
             inputModel.Response = inputModel.Input.Substring(0, 10);
         }
     });
 }
Beispiel #3
0
        public static void PreventSLetter(this InputProcessor processor)
        {
            processor.Processors.Add(inputModel =>
            {
                if (inputModel.Input.Contains('s'))
                {
                    inputModel.Response = "Letter s is not allowed blet";

                    processor.WriteResponse(inputModel);
                }
            });
        }
Beispiel #4
0
        public static void PreventEvenNumbers(this InputProcessor processor)
        {
            processor.Processors.Add(inputModel =>
            {
                int a;
                if (int.TryParse(inputModel.Input, out a))
                {
                    if (a % 2 == 0)
                    {
                        inputModel.Response = "Even number not allowed";

                        processor.WriteResponse(inputModel);
                    }
                }
            });
        }