Created
November 9, 2018 16:53
-
-
Save timcase/4186ec74bfc0d01ec5f438c636578e0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_bill | |
outstanding = 0.0 | |
#print banner | |
puts "*************************" | |
puts "******Customer Owes******" | |
puts "*************************" | |
# calculate outstanding | |
@orders.each do |order| | |
oustanding += order.amount | |
end | |
#print details | |
puts "name: #{@name}" | |
puts "amount: #{outstanding}" | |
end | |
def calculate_outstanding | |
@order.inject(0.0){ |result, order| result + order.amount] } | |
end | |
def print_banner | |
puts "*************************" | |
puts "******Customer Owes******" | |
puts "*************************" | |
end | |
def print_outstanding(outstanding) | |
puts "name: #{@name}" | |
puts "amount: #{outstanding}" | |
end | |
def print_bill | |
print_banner | |
outstanding = calculate_oustanding | |
print_outstanding(outstanding) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment