Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
p.145 introduce temporary variable "quantity_discount" .
  • Loading branch information
kono committed May 22, 2010
1 parent d0870bf commit 15bb3b2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion chapter6/Introduce_Explaining_Variable.rb
Expand Up @@ -8,8 +8,9 @@ def initialize(quantity, item_price)
def price
# 価格は、基本価格 - 数量割引 + 配送料
base_price = @quantity * @item_price
quantity_discount = [0, @quantity - 500].max * @item_price * 0.05
return base_price -
[0, @quantity - 500].max * @item_price * 0.05 +
quantity_discount +
[base_price * 0.1,100.0].min
end
end
Expand Down

0 comments on commit 15bb3b2

Please sign in to comment.