Exemplo n.º 1
0
        public void Handle(Order order, IPicture picture)
        {
            switch (mode)
            {
            case 1:
                if (order.Color == "red")
                {
                    nextMachine.Handle(order, new Picture(null, order.Color, null, mode));
                }
                else
                {
                    nextMachine.Handle(order, new Picture(null, "", null, mode));
                }
                break;

            case 2:
                if (order.Color == "red" || order.Color == "green" || order.Color == "blue")
                {
                    nextMachine.Handle(order, new Picture(null, order.Color, null, mode));
                }
                else
                {
                    nextMachine.Handle(order, new Picture(null, "", null, mode));
                }
                break;
            }
        }
Exemplo n.º 2
0
        public void Handle(Order order, IPicture picture)
        {
            Tuple <string, string> shape = null;

            switch (mode)
            {
            case 1:
                shape = null;
                if (picture.Color == null || picture.Text == null)
                {
                    Console.WriteLine("Error: Cannot be paint without Color or Text!");
                    return;
                }
                if (order.Shape == "circle")
                {
                    shape = new Tuple <string, string>("(", ")");
                }
                if (order.Shape == "square")
                {
                    shape = new Tuple <string, string>("[", "]");
                }
                if (shape == null)
                {
                    Console.WriteLine("Error: Cannot create picture!");
                    return;
                }
                nextMachine.Handle(order, new Picture(shape, picture.Color, picture.Text, mode));
                break;

            case 2:
                shape = null;
                if (picture.Color == null || picture.Text == null)
                {
                    Console.WriteLine("Error: Cannot be paint without Color or Text!");
                    return;
                }
                if (order.Shape == "circle")
                {
                    shape = new Tuple <string, string>("(", ")");
                }
                if (order.Shape == "square")
                {
                    shape = new Tuple <string, string>("[", "]");
                }
                if (order.Shape == "triangle")
                {
                    shape = new Tuple <string, string>("<", ">");
                }
                if (shape == null)
                {
                    Console.WriteLine("Error: Cannot create picture!");
                    return;
                }
                nextMachine.Handle(order, new Picture(shape, picture.Color, picture.Text, mode));
                break;
            }
        }
Exemplo n.º 3
0
        public void Handle(Order order, IPicture picture)
        {
            Picture pic = new Picture(picture);

            if (order.Color == "green")
            {
                pic.Color = order.Color;
            }
            nextMachine.Handle(order, pic);
        }
Exemplo n.º 4
0
        public void Handle(Order order, IPicture picture)
        {
            Picture pic = new Picture(picture);

            if (pic.Text == null)
            {
                pic.Text = order.Text;
            }
            nextMachine.Handle(order, pic);
        }
Exemplo n.º 5
0
        public void Handle(Order order, IPicture picture)
        {
            Picture pic = new Picture(picture);

            if (order.Operation == "uppercase")
            {
                pic.Text = order.Text.ToUpper();
            }
            nextMachine.Handle(order, pic);
        }
Exemplo n.º 6
0
        public void Handle(Order order, IPicture picture)
        {
            Picture pic = new Picture(picture);

            if (pic.Color == null)
            {
                pic.Color = string.Empty;
            }
            nextMachine.Handle(order, pic);
        }
Exemplo n.º 7
0
        public void Handle(Order order, IPicture picture)
        {
            Picture pic = new Picture(picture);

            if (order.Shape == "square")
            {
                pic.LeftFrame  = "[[";
                pic.RightFrame = "]]";
            }
            nextMachine.Handle(order, pic);
        }
Exemplo n.º 8
0
        public void Handle(Order order, IPicture picture)
        {
            Picture pic = new Picture(picture);

            if (order.Shape == "circle")
            {
                pic.LeftFrame  = "((";
                pic.RightFrame = "))";
            }
            nextMachine.Handle(order, pic);
        }
Exemplo n.º 9
0
 public void Handle(Order order, IPicture picture)
 {
     if (ValidOrder(order))
     {
         nextMachine.Handle(order, picture);
     }
     else
     {
         System.Console.WriteLine("Error: Invalid order!");
     }
 }
Exemplo n.º 10
0
        public void Handle(Order order, IPicture picture)
        {
            switch (mode)
            {
            case 1:
                nextMachine.Handle(order, new Picture(null, picture.Color, order.Text, mode));
                break;

            case 2:
                string text = order.Text;
                if (order.Operation == "uppercase")
                {
                    text = order.Text.ToUpper();
                }
                if (order.Operation == "spacing")
                {
                    text = Regex.Replace(order.Text, ".{1}", "$0 ").Trim();
                }
                nextMachine.Handle(order, new Picture(null, picture.Color, text, mode));
                break;
            }
        }
Exemplo n.º 11
0
        public void Handle(Order order, IPicture picture)
        {
            Picture pic = new Picture(picture);

            if (pic.LeftFrame == null)
            {
                System.Console.WriteLine("Error: Cannot create picture!");
            }
            else
            {
                nextMachine.Handle(order, pic);
            }
        }
Exemplo n.º 12
0
 public void Handle(Order order, IPicture picture)
 {
     if (order.Shape != null && order.Color != null && order.Text != null && order.Operation != null &&
         order.Shape != "" && order.Color != "" && order.Text != "" && order.Operation != "" &&
         Regex.IsMatch(order.Shape, @"^[a-zA-Z]+$") &&
         Regex.IsMatch(order.Color, @"^[a-zA-Z]+$") &&
         Regex.IsMatch(order.Text, @"^[a-zA-Z]+$") &&
         Regex.IsMatch(order.Operation, @"^[a-zA-Z]+$"))
     {
         nextMachine.Handle(order, picture);
     }
     else
     {
         Console.WriteLine("Error: Invalid order!");
     }
 }
Exemplo n.º 13
0
        public void Handle(Order order, IPicture picture)
        {
            Picture pic = new Picture(picture);

            if (order.Operation == "spacing")
            {
                char[]        chars         = order.Text.ToCharArray();
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < chars.Length - 1; i++)
                {
                    stringBuilder.Append(chars[i]).Append(" ");
                }
                stringBuilder.Append(chars[chars.Length - 1]);
                pic.Text = stringBuilder.ToString();
            }
            nextMachine.Handle(order, pic);
        }
Exemplo n.º 14
0
 public string Handle(List <string> comands, string name)
 {
     if (name == option)
     {
         foreach (string comand in comands)
         {
             if (comand.Length >= get.Length && comand.Substring(0, get.Length) == get)
             {
                 string ret = comand.Substring(get.Length);
                 if (ret == null)
                 {
                     return(string.Empty);
                 }
                 return(ret);
             }
         }
     }
     return(nextMachine.Handle(comands, name));
 }
Exemplo n.º 15
0
 public string Handle(List <string> comands, string name)
 {
     if (name == option)
     {
         foreach (string comand in comands)
         {
             if (comand.Length >= first.Length + second.Length &&
                 comand.Substring(0, first.Length) == first &&
                 comand.Substring(comand.Length - second.Length, second.Length) == second)
             {
                 string ret = comand.Substring(first.Length, comand.Length - first.Length - second.Length);
                 if (ret == null)
                 {
                     return(string.Empty);
                 }
                 return(ret);
             }
         }
     }
     return(nextMachine.Handle(comands, name));
 }
Exemplo n.º 16
0
        public void Handle(Order order, IPicture picture)
        {
            Picture pic = new Picture(picture);

            if (order.Shape == "triangle" && pic.Color == string.Empty && order.Operation == "spacing")
            {
                pic.LeftFrame  = "<<<";
                pic.RightFrame = ">>>";
            }
            else if (order.Shape == "triangle" && (pic.Color == string.Empty || order.Operation == "spacing"))
            {
                pic.LeftFrame  = "<<";
                pic.RightFrame = ">>";
            }
            else if (order.Shape == "triangle")
            {
                pic.LeftFrame  = "<";
                pic.RightFrame = ">";
            }
            nextMachine.Handle(order, pic);
        }