Example #1
0
        static void Main(string[] args)
        {
            TaxVisitor taxVisitor = new TaxVisitor();

            HardFood  biskit   = new HardFood(20.18);
            Tobacco   goldLief = new Tobacco(50.518);
            Chocolate kitkat   = new Chocolate(70.958);

            Console.WriteLine("price+tax: " + biskit.accept(taxVisitor));
            Console.WriteLine("price+tax: " + goldLief.accept(taxVisitor));
            Console.WriteLine("price+tax: " + kitkat.accept(taxVisitor));
        }
Example #2
0
 public double visit(HardFood hardFood)
 {
     return(hardFood.getPrice() + hardFood.getPrice() * 0.10);
 }