Beispiel #1
0
        static void Main(string[] args)
        {
            int        cantidad = 0;
            string     tipo     = "";
            Iprimitiva calidad  = null;
            double     total    = 0;;

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("1-barato, 2-normal");
            tipo = Console.ReadLine();

            if (tipo.Equals("1"))
            {
                calidad = new Barato();
            }
            if (tipo.Equals("2"))
            {
                calidad = new Normal();
            }
            Console.WriteLine("cuantos a producir?");
            cantidad = Convert.ToInt32(Console.ReadLine());


            Algoritmo producion = new Algoritmo();


            total = producion.metodoTemplate(calidad, cantidad);


            Console.ForegroundColor = ConsoleColor.Gray;

            Console.WriteLine("el total es:{0}", total);
            Console.ReadKey();
        }
        public double metodoTemplate(Iprimitiva tipo, int cantidad)
        {
            double total = 0;

            //crear juguete
            total += crearjuguete(cantidad);

            //lo decoramos
            total += tipo.Decorar(cantidad);

            //verificar cantidad
            calidad();

            //empacamos
            total += tipo.Empacar(cantidad);
            return(total);
        }