예제 #1
0
        static void Main(string[] args)
        {
            InputProcessor input = new InputProcessor(); // new object of InputProcessor classs

            input.PreventSLetter();
            input.PreventEvenNumbers();
            input.SetResponceTo10CharsOfInput();
            input.Process();
        }
예제 #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);
         }
     });
 }
예제 #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);
                }
            });
        }
예제 #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);
                    }
                }
            });
        }