Exemplo n.º 1
0
        // warning: beware of bool method arguments
        // Their appearance is the indicator of leaving the OO design principles
        private static void ClaimWarrenty(SoldArticle article)  // bool flags
        {
            DateTime now = DateTime.Now;

            article.MoneyBackGuarantee.Claim(now, () => Console.WriteLine("Offer money back"));
            article.ExpressWarranty.Claim(now, () => Console.WriteLine("Offer repair"));
        }
Exemplo n.º 2
0
        public void Main()
        {
            DateTime sellingDate   = new DateTime(2019, 12, 9);
            TimeSpan moneyBackSpan = TimeSpan.FromDays(30);

            IWarranty   warranty = new LifetimeWarranty(sellingDate);
            SoldArticle goods    = new SoldArticle(warranty, warranty);

            ClaimWarrenty(goods);
        }