05 - Factory Method structural.doc - Factory Method pattern Structural example using System namespace DoFactory.GangOfFour.Factory.Structural <summary>

05 - Factory Method structural.doc - Factory Method pattern...

This preview shows page 1 - 3 out of 3 pages.

// Factory Method pattern -- Structural example using System; namespace DoFactory.GangOfFour.Factory.Structural { /// <summary> /// MainApp startup class for Structural /// Factory Method Design Pattern. /// </summary> class MainApp { /// <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(); }
Image of page 1

Subscribe to view the full document.

} /// <summary> /// The 'Product' abstract class /// </summary> abstract class
Image of page 2
Image of page 3
  • Fall '19
  • Martha

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes