Skip to content

Commit

Permalink
p.132-p.133 extract method "calculate_outstanding"
Browse files Browse the repository at this point in the history
  • Loading branch information
kono committed May 11, 2010
1 parent a398e15 commit 693fe14
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions chapter6/Extract_Method.rb
Expand Up @@ -17,15 +17,8 @@ def order_entry(amount)
end

def print_owing
outstanding = 0.0

print_banner

#勘定を計算(calculate outstanding)
@orders.each do |order|
outstanding += order.amount
end

outstanding = calculate_outstanding
print_details outstanding
end

Expand All @@ -43,3 +36,11 @@ def print_details(outstanding)
puts "name: #{@name}"
puts "amount: #{outstanding}"
end

def calculate_outstanding
outstanding = 0.0
@orders.each do |order|
outstanding += order.amount
end
outstanding
end

0 comments on commit 693fe14

Please sign in to comment.