Skip to content

Instantly share code, notes, and snippets.

@nolleto
Created June 13, 2018 13:33
Show Gist options
  • Save nolleto/8b503ea55707fc08e3bcdaef7a910c91 to your computer and use it in GitHub Desktop.
Save nolleto/8b503ea55707fc08e3bcdaef7a910c91 to your computer and use it in GitHub Desktop.
Updace overview
class Tipper
TAX = 0.05
def initialize(amount:, discount_percentage: 0, tip_percentage:)
@amount = amount
@discount_percentage = discount_percentage
@tip_percentage = tip_percentage
end
def total
tax = amount * TAX # change to `tax = amount`
discount = amount * (discount_percentage / 100.0)
tip = amount * (tip_percentage / 100.0) # tip = amount * (tip_percentage / 100.0)
amount + tax - discount + tip
end
private
attr_reader :amount, :discount_percentage, :tip_percentage
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment