Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Liquor vodka = new Liquor(95);

            Console.WriteLine(vodka);

            IVisitor endOfYearVisitor = new EndOfYearTax();

            Console.WriteLine($"Price after tax = {vodka.Accept(endOfYearVisitor)}");

            SomeProduct someProduct = new SomeProduct(213);

            Console.WriteLine(someProduct);

            Console.WriteLine($"Price after tax = {someProduct.Accept(endOfYearVisitor)}");

            Console.WriteLine($"Price after gift = {someProduct.Accept(new GiftVisitor())}");

            Console.WriteLine($"Price after gift = {vodka.Accept(new GiftVisitor())}");

            Console.WriteLine("*******************************************");

            Shop shop = new Shop(1000);

            Console.WriteLine(shop);

            Console.WriteLine($"Price after gift = {shop.Accept(new GiftVisitor())}");

            Console.WriteLine($"Price after tax = {shop.Accept(endOfYearVisitor)}");
        }
Exemplo n.º 2
0
 public double Visit(SomeProduct someProduct)
 {
     return(someProduct.Price * 5);
 }
Exemplo n.º 3
0
 public double Visit(SomeProduct chocolate)
 {
     return(1);
 }