TemplateMethod() 공개 메소드

public TemplateMethod ( ) : void
리턴 void
예제 #1
0
            /*
             *  Klientkoden kallar template-metoden för att utföra algoritmen
             *  Klienten behöver veta vilken konkret klass som används
             */

            public static void ClientCode(AbstractClass abstractClass)
            {
                // ...
                abstractClass.TemplateMethod(); // Denna metod ligger den enda som är synlig utåt och sitter på den abstrakta basklassen
                // ...
            }
예제 #2
0
 // The client code calls the template method to execute the algorithm.
 // Client code does not have to know the concrete class of an object it
 // works with, as long as it works with objects through the interface of
 // their base class.
 public static void ClientCode(AbstractClass abstractClass)
 {
     // ...
     abstractClass.TemplateMethod();
     // ...
 }
예제 #3
0
        public void MakeWords()
        {
            parametersGroup.Attach(new Parameter(1, 2.5, "black"));
            int x = 0;

            for (int i = 0; i < 9; i++)
            {
                if (i <= 2)
                {
                    Console.WriteLine("FIRST LEVEL");
                    Word[] list = firstLevel.TemplateMethod();
                    collection[x] = list[0];
                    x++;
                    collection[x] = list[1];
                    x++;
                    collection[x] = list[2];
                    x++;

                    Composite word     = new Composite(list[0].word);
                    Composite letters  = new Composite(list[1].word);
                    Composite sentence = new Composite(list[2].word);

                    letters.Add(sentence);
                    word.Add(letters);
                    word.Display(1);

                    collection[x] = new Composite(word.getSequence());
                    x++;
                }

                if (i >= 3 && i <= 5)
                {
                    Console.WriteLine("SECOND LEVEL");
                    Word[] list = secondLevel.TemplateMethod();
                    collection[x] = list[0];
                    x++;
                    collection[x] = list[1];
                    x++;
                    collection[x] = list[2];
                    x++;

                    Composite word     = new Composite(list[0].word);
                    Composite letters  = new Composite(list[1].word);
                    Composite sentence = new Composite(list[2].word);

                    letters.Add(sentence);
                    word.Add(letters);
                    word.Display(1);

                    collection[x] = new Composite(word.getSequence());
                    x++;
                }

                if (i >= 6)
                {
                    Console.WriteLine("Third LEVEL");
                    Word[] list = thirdLevel.TemplateMethod();
                    collection[x] = list[0];
                    x++;
                    collection[x] = list[1];
                    x++;
                    collection[x] = list[2];
                    x++;

                    Composite word     = new Composite(list[0].word);
                    Composite letters  = new Composite(list[1].word);
                    Composite sentence = new Composite(list[2].word);

                    letters.Add(sentence);
                    word.Add(letters);
                    word.Display(1);

                    collection[x] = new Composite(word.getSequence());
                    x++;
                }
            }

            Console.WriteLine(collection[0]);
        }
예제 #4
0
 /// <summary>
 /// The client code calls the template method to execute the algorithm.
 /// Client code does not have to know the concrete class of an object it works with,
 /// as long as it works with objects through the interface of their base class.
 /// </summary>
 /// <param name="abstractClass"></param>
 private void ClientCode(AbstractClass abstractClass)
 {
     // ...
     abstractClass.TemplateMethod();
     // ...
 }
예제 #5
0
 /// <summary>
 /// The client code calls the template method to execute the algorithm.
 /// Client code does not have to know the concrete class of an object it works with,
 /// as long as it works with objects through the interface of their base class.
 /// </summary>
 /// <param name="abstractClass">Abstract class.</param>
 public static void ProcessSomething(AbstractClass abstractClass)
 {
     // Initial operations
     abstractClass.TemplateMethod();
     // Additional operations
 }
예제 #6
0
 public void TemplateMethodExecuted()
 {
     Assert.AreEqual(3, _templateMethod.TemplateMethod());
 }
예제 #7
0
 public void ClientCode(AbstractClass abstractClass)
 {
     abstractClass.TemplateMethod();
 }