Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmo91/d732e05a6f9874276e410fbfa0a3f155 to your computer and use it in GitHub Desktop.
Save fmo91/d732e05a6f9874276e410fbfa0a3f155 to your computer and use it in GitHub Desktop.
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