Created
November 4, 2019 04:00
-
-
Save fmo91/d732e05a6f9874276e410fbfa0a3f155 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductsCalculator { | |
private let taxesCalculator: TaxesCalculatorType | |
// ... | |
init(taxesCalculator: TaxesCalculatorType) { | |
self.taxesCalculator = taxesCalculator | |
} | |
func calculateTotal() -> Double { | |
let subtotal = products.map({ $0.price }).reduce(0, +) | |
return taxesCalculator.applyTaxes(to: subtotal) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment