コード例 #1
0
        public static ICreditPolice CreateCreditPolice(EnumPolice enumPolice)
        {
            ICreditPolice creditPolice = null;


            switch (enumPolice)
            {
            case EnumPolice.AGE:
                creditPolice = FactoryPattern <ICreditPolice, AgePolice> .CreateInstance();

                break;

            case EnumPolice.SCORE:
                creditPolice = FactoryPattern <ICreditPolice, ScorePolice> .CreateInstance();

                break;

            case EnumPolice.COMMITMENT:
                creditPolice = FactoryPattern <ICreditPolice, CommitmentPolice> .CreateInstance();

                break;

            default:
                break;
            }

            return(creditPolice);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            #region Factory example 1

            Console.WriteLine("Factory Method Example 1 with email server.");
            Console.WriteLine();
            FactoryExample1ClientCode.Run();

            #endregion

            #region DoFactory GangOfFour FactoryMethod Structural example

            Console.WriteLine("Gang Of Four Factory Method Structural example");
            Console.WriteLine();

            GofFFacotryExample.Run();

            #endregion

            #region Factory Method Avocado Shop Example

            Console.WriteLine("Factory Pattern Avocado Shop Example");
            Console.WriteLine();
            FactoryPattern.Run();

            #endregion

            Console.Read();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: AayushJain31/Learning2020
        static void Main(string[] args)
        {
            IStudent S = FactoryPattern.Create(0);
            int      x = S.Pay();

            Console.WriteLine("Student has paid the Fees Amount : " + x);

            S = FactoryPattern.Create(1);
            int y = S.Pay();

            Console.WriteLine("Student has paid the Fine Amount : " + y);

            Console.Read();
        }
コード例 #4
0
 /// <summary>
 /// Design Patterns:-
 ///
 /// Design patterns are solutions to software design problems you find again and again in real-world application development.
 /// Patterns are about reusable designs and interactions of objects.
 ///
 /// The 23 Gang of Four (GoF) patterns are generally considered the foundation for all other patterns.
 /// They are categorized in three groups: Creational, Structural and Behavioral.
 ///
 /// CREATIONAL PATTERNS:-
 ///    1) Abstract Factory --> Creates an instance of several families of classes
 ///    2) Factory Method   --> Creates an instance of several derived classes
 ///    3) Singleton        --> A class of which only a single instance can exist
 ///    4) Prototype        --> A fully initialized instance to be copied or cloned
 ///    5) Builder          --> Separates object construction from its representation
 ///
 /// STRUCTURAL PATTERNS:-
 ///
 ///
 /// BEHAVIORAL PATTERNS:-
 ///
 ///
 /// </summary>
 public static void Factory()
 {
     //Example of 1) Abstract Factory and 2) Factory Method
     FactoryPattern.FactoryMethod();
 }