예제 #1
0
        static void Main(string[] args)
        {
            var booksComposite = new CompositeComponent <ILibrary> {
                Node = new Category("Books")
            };

            var scienceBooks = booksComposite.Add(new Category("Science"));

            var bk1 = scienceBooks.Add(new Book("Vakıf"));
            var bk2 = scienceBooks.Add(new Book("Kaplan Kaplan!"));

            var fantasticComposite = booksComposite.Add(new Category("Fantastic"));
            var fl = fantasticComposite.Add(new Book("Yüzüklerin Efendisi"));

            booksComposite.List(1);


            //Category books = new Category("Kitap");
            //Category science = new Category("Bilim Kurgu");
            //Category fantastic = new Category("Fantastik");

            //Book scienceBook1 = new Book("Vakıf");
            //Book scienceBook2 = new Book("Kaptan Kaptan");
            //Book scienceBook3 = new Book("Yüzüklerin Efendisi");

            //books.Add(science);
            //books.Add(fantastic);

            //science.Add(scienceBook1);
            //science.Add(scienceBook2);

            //fantastic.Add(scienceBook3);
            //books.Show(1);
            Console.ReadLine();
        }
예제 #2
0
        public CompositeComponent <T> Add(T componentObje)
        {
            CompositeComponent <T> newNode = new CompositeComponent <T> {
                Node = componentObje
            };

            subComponents.Add(newNode);
            return(newNode);
        }