Exemplo n.º 1
0
        private Bouqet FindByColor(string color)
        {
            Bouqet b = new Bouqet();

            foreach (var flower in _bouqet)
            {
                if (flower.Color == color)
                {
                    b.Add(flower);
                }
            }
            return(b);
        }
Exemplo n.º 2
0
        public Bouqet ExecuteCommand(Comand command, string param)
        {
            Bouqet b = new Bouqet();

            switch (command)
            {
            case Comand.FindByColor:
                b = FindByColor(param);
                return(b);

            case Comand.SortByParam:
                SortByName();
                break;
            }

            return(b);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Bouqet b = new Bouqet {
                new Rose("Name", "White", 2100), new Cactus("Cact", "Purple", 1000), new Rose()
            };
            BouqetController bc = new BouqetController(b);


            BouqetController.Comand find = BouqetController.Comand.FindByColor;
            BouqetController.Comand sort = BouqetController.Comand.SortByParam;

            Bouqet res = bc.ExecuteCommand(find, "Red");

            Printer.Print(res);

            bc.ExecuteCommand(sort, null);
            Printer.Print(b);

            Console.WriteLine("Цена букета: " + bc.TotalPrice().ToString());


            Paper        p1        = new Paper("Shit Paper", Paper.Quality.Good);
            Paper        p2        = new Paper("Another Shit Paper", Paper.Quality.Bad);
            List <Paper> paperList = new List <Paper> {
                p1, p2
            };

            foreach (var el in paperList)
            {
                Console.WriteLine(el.name);
            }

            Console.WriteLine();
            p2      = p1;
            p1.name = "Not rly shit paper";
            Console.WriteLine(p1.name);
            Console.WriteLine(p2.name);
            Console.WriteLine();

            foreach (var el in paperList)
            {
                Console.WriteLine(el.name);
            }
        }
Exemplo n.º 4
0
 public BouqetController(Bouqet bouqet)
 {
     _bouqet = bouqet;
 }