Exemple #1
0
 public static StudentFactory getStudentFactory()
 {
     if (studentFactory == null)
     {
         studentFactory = new StudentFactory();
     }
     return(studentFactory);
 }
Exemple #2
0
        static void Main(string[] args)
        {
            UserFactory teacher_user = new TeacherFactory();
            Client      c1           = new Client(teacher_user);

            Console.WriteLine("User: {0}    Allowed {1}", c1.TypeUsr(), c1.ToString());

            UserFactory student_user = StudentFactory.getStudentFactory();
            Client      c2           = new Client(student_user);

            Console.WriteLine("User: {0}    Allowed {1}", c2.TypeUsr(), c2.ToString());
        }
Exemple #3
0
        static void Main(string[] args)
        {
            // Student factory creates only students
            var sortingClient = new SortingClient <Student>(new StudentFactory(), 10);

            sortingClient.Sort();

            // Groceries factory creates only groceries
            var sortingClient2 = new SortingClient <Groceries>(new GroceryFactory(), 10);

            sortingClient2.Sort();

            // To show that is possible to instantiate a single item (grocery or student)
            var     studentFactory = new StudentFactory();
            Student student        = studentFactory.BuildItem();

            var       groceryFactory = new GroceryFactory();
            Groceries grocerie       = groceryFactory.BuildItem();

            Console.WriteLine(student.Name);
            Console.WriteLine(grocerie.Name);
        }