コード例 #1
0
        private double CalculateTax(Product product)
        {
            double  taxToApply        = 0;
            BaseTax baseTax           = new BaseTax(product);
            double  calculatedBaseTax = baseTax.Calculate();

            taxToApply += calculatedBaseTax;

            if (product.Category == ProductCategory.Other)
            {
                RegularTax regularTax           = new RegularTax(product);
                double     calculatedRegularTax = regularTax.Calculate();
                taxToApply += calculatedRegularTax;
            }

            if (product.IsImported)
            {
                ImportTax importTax           = new ImportTax(product);
                double    calculatedImportTax = importTax.Calculate();
                taxToApply += calculatedImportTax;
            }

            return(taxToApply);
        }
コード例 #2
0
 public void Calculate(BaseTax tax)
 {
     tax.Calculate();
 }