Ejemplo n.º 1
0
        void OnEnable()
        {
            Debug.Log("------------------");
            Debug.Log("VISITOR DESIGN PATTERN");

            // testing the pattern:

            TaxVisitor        taxCalc        = new TaxVisitor();
            TaxHolidayVisitor taxHolidayCalc = new TaxHolidayVisitor();

            Necessity milk   = new Necessity(3.25);
            Liquor    vodka  = new Liquor(11.99);
            Tobacco   cigars = new Tobacco(19.99);

            double milkPrice        = milk.Accept(taxCalc);
            double milkPriceHoliday = milk.Accept(taxHolidayCalc);

            Debug.Log("Milk costs: " + milkPrice.ToString() + ", Holiday Price: " + milkPriceHoliday.ToString());

            double vodkaPrice        = vodka.Accept(taxCalc);
            double vodkaHolidayPrice = vodka.Accept(taxHolidayCalc);

            Debug.Log("Vodka costs: " + vodkaPrice.ToString() + ", Holiday Price: " + vodkaHolidayPrice.ToString());

            double cigarsPrice        = cigars.Accept(taxCalc);
            double cigarsPriceHoliday = cigars.Accept(taxHolidayCalc);

            Debug.Log("Cigars cost: " + cigarsPrice.ToString() + ", Holiday Price: " + cigarsPriceHoliday.ToString());
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        public void Test()
        {
            //// Arrange
            TaxVisitor taxVisitor = new TaxVisitor();

            Milk milk = new Milk(2);



            //// Act
            double priceWithTax = milk.Accept(taxVisitor);

            Console.WriteLine(priceWithTax);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            TaxVisitor taxCalc = new TaxVisitor();

            Necessity milk   = new Necessity(3.47);
            Liquor    vodka  = new Liquor(11.99);
            Tobacco   cigars = new Tobacco(19.99);


            Console.WriteLine($"{milk.Accept(taxCalc)}");
            Console.WriteLine($"{vodka.Accept(taxCalc)}");
            Console.WriteLine($"{cigars.Accept(taxCalc)}");

            Console.ReadKey();
        }
        void OnEnable()
        {
            Debug.Log ("------------------");
            Debug.Log ("VISITOR DESIGN PATTERN");

            // testing the pattern:

            TaxVisitor taxCalc = new TaxVisitor();
            TaxHolidayVisitor taxHolidayCalc = new TaxHolidayVisitor();

            Necessity milk = new Necessity(3.25);
            Liquor vodka = new Liquor(11.99);
            Tobacco cigars = new Tobacco(19.99);

            double milkPrice = milk.Accept(taxCalc);
            double milkPriceHoliday = milk.Accept(taxHolidayCalc);
            Debug.Log ("Milk costs: " + milkPrice.ToString() + ", Holiday Price: " + milkPriceHoliday.ToString());

            double vodkaPrice = vodka.Accept(taxCalc);
            double vodkaHolidayPrice = vodka.Accept(taxHolidayCalc);
            Debug.Log ("Vodka costs: " + vodkaPrice.ToString() + ", Holiday Price: " + vodkaHolidayPrice.ToString());

            double cigarsPrice = cigars.Accept(taxCalc);
            double cigarsPriceHoliday = cigars.Accept(taxHolidayCalc);
            Debug.Log ("Cigars cost: " + cigarsPrice.ToString() + ", Holiday Price: " + cigarsPriceHoliday.ToString());
        }