Skip to content

Commit

Permalink
p.140 extract method "discount_factor".
Browse files Browse the repository at this point in the history
  • Loading branch information
kono committed May 22, 2010
1 parent 13bdff4 commit ddcfcf9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions chapter6/Replace_Temp_with_Query.rb
Expand Up @@ -7,15 +7,15 @@ def initialize(quantity, price)


def price
if base_price >1000
discount_factor = 0.95
else
discount_factor = 0.98
end
base_price * discount_factor
a_discount_factor = discount_factor
base_price * a_discount_factor
end

def base_price
@quantity * @item_price
end

def discount_factor
base_price > 1000 ? 0.95 : 0.98
end
end

0 comments on commit ddcfcf9

Please sign in to comment.