Accept() публичный Метод

public Accept ( Visitor visitor ) : double
visitor Visitor
Результат double
Пример #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());
        }
Пример #2
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());
        }