Esempio n. 1
0
 private static void Report(string issuer, Product product)
 {
     Console.WriteLine();
     Console.WriteLine(new string('=', 50));
     Console.WriteLine($"\t{issuer}");
     Console.WriteLine($"\tproduct: {product.GetType().Name}");
     Console.WriteLine(new string('=', 50));
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Creator creator = new ConcreteCreatorA();

            Product prod = creator.FactoryMethod();


            Console.WriteLine(prod.GetType());
            Console.ReadKey();
        }
Esempio n. 3
0
 static void Main(string[] args)
 {
     Factory[] factories = new Factory[2];
     factories[0] = new Factory1();
     factories[1] = new Factory2();
     foreach (Factory factory in factories)
     {
         Product product = factory.Create();
         Console.WriteLine(product.GetType().Name + " by " + factory.GetType().Name);
     }
     Console.ReadKey();
 }
Esempio n. 4
0
 public static void Main()
 {
     // an array of creators
     Creator[] creators = { new ConcreteCreatorA(), new ConcreteCreatorB() };
     // iterate over creators and create products
     foreach (Creator creator in creators)
     {
         Product product = creator.FactoryMethod();
         Console.WriteLine("Created {0}", product.GetType());
     }
     // Wait for user
     Console.Read();
 }
Esempio n. 5
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {
            // An array of creators
            Creator[] creators = new Creator[2];

            creators[0] = new ConcreteCreatorA();
            creators[1] = new ConcreteCreatorB();

            // Iterate over creators and create products
            foreach (Creator creator in creators)
            {
                Product product = creator.FactoryMethod();
                Console.WriteLine("Created {0}",
                                  product.GetType().Name);
            }

            // Wait for user
            Console.ReadKey();
        }
Esempio n. 6
0
        static void Main()
        {
            //Luuakse jada "creators", mis koosneb kahest liikmest:
            Creator[] creators = new Creator[2];
            //Need 2 jada liiget, mis tekitavad 2 uut konkreetset "creatorit", vastavalt Creatori alamklassidele ConcreteCreatorA ja ConcreteCreatorB.
            creators[0] = new ConcreteCreatorA();
            creators[1] = new ConcreteCreatorB();

            //Läbi foreach tsükli luuakse tooted, prinditakse konsoolile toote nimi
            foreach (Creator creator in creators)
            {
                Product product = creator.FactoryMethod();
                Console.WriteLine("Created {0}",
                                  product.GetType().Name);
            }



            Console.ReadLine();
        }