public Biller GetBiller(string strategy)
        {
            TaxCalculatorFactory factory = new TaxCalculatorFactory();
            ITaxCalculator       taxCal  = factory.GetTaxCalculator(strategy);

            return(new Biller(taxCal));
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // Variables
            // double basePrice = 10;
            // double pricePerTopping = 1;
            PriceDefinition priceDefinition = new PriceDefinition
            {
                BasePrice    = 10,
                PricePerUnit = 1
            };
            TaxCalculatorFactory taxFactory = new TaxCalculatorFactory();

            // User input
            Console.WriteLine("Enter your province and press enter:");
            string province = Console.ReadLine();

            Console.WriteLine("Enter the number of toppings and press enter:");
            string toppings = Console.ReadLine();

            // Calculation
            int    numberOfToppings = int.Parse(toppings);
            var    pizza            = new Pizza(taxFactory.GetTaxCalculator(province), numberOfToppings, priceDefinition);
            double total            = pizza.CalculatePrice();

            // Output
            Console.WriteLine($"Order total is: {total}");
            Console.WriteLine("Press any key to exit");
            Console.Read();
        }
Esempio n. 3
0
        public void CreateAlbertaTaxCalculator()
        {
            var            taxCalculatorFactory = new TaxCalculatorFactory();
            ITaxCalculator result = taxCalculatorFactory.GetTaxCalculator("AB");

            Assert.IsType <AlbertaTaxCalculator>(result);
        }
Esempio n. 4
0
        void Initialize()
        {
            country = "Local";
            TaxCalculatorFactory factory = new TaxCalculatorFactory();

            taxCal = factory.GetTaxCalculator(country);
            biller = new Biller(taxCal);
        }