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

Commit

Permalink
move points to Rental
Browse files Browse the repository at this point in the history
  • Loading branch information
edgenard committed Jul 30, 2018
1 parent e841b02 commit 6686d38
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions a_first_example/first_example.rb
Expand Up @@ -24,6 +24,19 @@ def charge
base_charge + extra_charge
end

def points
case movie.price_code
when Movie::CHILDRENS, Movie::REGULAR
1
when Movie::NEW_RELEASE
if days_rented > 1
2
else
1
end
end
end

private

def base_charge
Expand Down Expand Up @@ -77,7 +90,7 @@ def statement

this_amount += rental.charge

frequent_renter_points += points_for_rental(rental)
frequent_renter_points += rental.points

# show figures for this rental
result += "\t" + rental.movie.title + "\t" + this_amount.to_s + "\n"
Expand All @@ -89,16 +102,4 @@ def statement
result
end

def points_for_rental(rental)
case rental.movie.price_code
when Movie::CHILDRENS, Movie::REGULAR
1
when Movie::NEW_RELEASE
if rental.days_rented > 1
2
else
1
end
end
end
end

0 comments on commit 6686d38

Please sign in to comment.