Example #1
0
        static void Main(string[] args)
        {
            List <Manuscript> manuscripts = new List <Manuscript>();

            // Instantiate the formatters
            IFormatter standardFormatter  = new StandardFormatter();
            IFormatter backwardsFormatter = new BackwardsFormatter();
            IFormatter fancyFormatter     = new FancyFormatter();

            FAQ faq = new FAQ(standardFormatter);

            faq.QuestionAnswers.Add("Question 1", "Hello World");
            faq.QuestionAnswers.Add("Question 2", "May the force be with you");
            faq.QuestionAnswers.Add("Question 3", "Rest in Peace!");
            manuscripts.Add(faq);

            Book book = new Book("New book of patterns", "Raghu", "John Doe", backwardsFormatter);

            manuscripts.Add(book);

            Manuscript paper = new Paper("Design Patterns", "Wiki", "Ravi", "Nothing", fancyFormatter);

            manuscripts.Add(paper);

            foreach (var item in manuscripts)
            {
                item.Print();
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            List<Manuscript> manuscripts = new List<Manuscript>();

            // Instantiate the formatters
            IFormatter standardFormatter = new StandardFormatter();
            IFormatter backwardsFormatter = new BackwardsFormatter();
            IFormatter fancyFormatter = new FancyFormatter();

            FAQ faq = new FAQ(standardFormatter);
            faq.QuestionAnswers.Add("Question 1", "Hello World");
            faq.QuestionAnswers.Add("Question 2", "May the force be with you");
            faq.QuestionAnswers.Add("Question 3", "Rest in Peace!");
            manuscripts.Add(faq);

            Book book = new Book("New book of patterns", "Raghu", "John Doe", backwardsFormatter);
            manuscripts.Add(book);

            Manuscript paper = new Paper("Design Patterns", "Wiki", "Ravi", "Nothing", fancyFormatter);
            manuscripts.Add(paper);

            foreach (var item in manuscripts)
            {
                item.Print();
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            List <Manuscript> documents = new List <Manuscript>();

            var standFormatter = new StandardFormatter();
            var faq            = new FAQ(standFormatter);

            faq.Title = "The Bridge Pattern FAq";
            faq.Questions.Add("What is it?", "A design pattern");
            faq.Questions.Add("When do we use it?", "When you need to seperate an abstraction from an implementation");
            documents.Add(faq);


            var backwardsFormatter = new BackwardsFormatter();
            var book = new Book(backwardsFormatter)
            {
                Title  = "Design Patterns",
                Author = "Adrian Gurnett",
                Text   = "Blah blah blah"
            };

            documents.Add(book);


            var fancyFormatter = new FancyFormatter();
            var paper          = new TermPaper(fancyFormatter)
            {
                Class      = "Design Patterns",
                Student    = "Joe N00b",
                Text       = "Blah blah blah",
                References = "GOF"
            };

            documents.Add(paper);


            foreach (var document in documents)
            {
                document.Print();
            }


            Console.ReadKey();
        }