Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 44e7357

Browse files
committed
Page 35: Replacing the Conditional Logic on Price Code with Polymorphism (move Rental.frequent_renter_points to Movie.frequent_renter_points)
1 parent 371e47e commit 44e7357

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

‎chapter_1.rb‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ def charge(days_rented)
2424
end
2525
result
2626
end
27+
28+
def frequent_renter_points(days_rented)
29+
(price_code == Movie::NEW_RELEASE && days_rented > 1) ? 2 : 1
30+
end
2731
end
2832

2933
class Rental
@@ -38,7 +42,7 @@ def charge
3842
end
3943

4044
def frequent_renter_points
41-
(movie.price_code == Movie::NEW_RELEASE && days_rented > 1) ? 2 : 1
45+
movie.frequent_renter_points(days_rented)
4246
end
4347
end
4448

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /