Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Commit

Permalink
remove duplicate base_cost_of_movie calls
Browse files Browse the repository at this point in the history
  • Loading branch information
edgenard committed Jul 29, 2018
1 parent a17cb0e commit 2ccc5b5
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions a_first_example/first_example.rb
Expand Up @@ -40,14 +40,12 @@ def statement
this_amount = 0

# determine amounts for each line
this_amount += base_cost_of_movie(rental)

This comment has been minimized.

Copy link
@bbimeredithedwards

bbimeredithedwards Jul 31, 2018

why don't you have to call this in every "when" piece now?

case rental.movie.price_code
when Movie::REGULAR
this_amount += base_cost_of_movie(rental)
this_amount += (rental.days_rented - 2) * 1.5 if rental.days_rented > 2
when Movie::NEW_RELEASE
this_amount += base_cost_of_movie(rental) #base cost of movie
when Movie::CHILDRENS
this_amount += base_cost_of_movie(rental)
this_amount += (rental.days_rented - 3) * 1.5 if rental.days_rented > 3
end

Expand Down

0 comments on commit 2ccc5b5

Please sign in to comment.