We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c18818 commit 80cd752Copy full SHA for 80cd752
chapter_1.rb
@@ -17,6 +17,21 @@ class Rental
17
def initialize(movie, days_rented)
18
@movie, @days_rented = movie, days_rented
19
end
20
+
21
+ def charge
22
+ result = 0
23
+ case movie.price_code
24
+ when Movie::REGULAR
25
+ result += 2
26
+ result += (days_rented - 2) * 1.5 if days_rented > 2
27
+ when Movie::NEW_RELEASE
28
+ result += days_rented * 3
29
+ when Movie::CHILDRENS
30
+ result += 1.5
31
+ result += (days_rented - 3) * 1.5 if days_rented > 3
32
+ end
33
+ result
34
35
36
37
@@ -55,18 +70,7 @@ def statement
55
70
56
71
57
72
def amount_for(rental)
58
- result = 0
59
- case rental.movie.price_code
60
- when Movie::REGULAR
61
- result += 2
62
- result += (rental.days_rented - 2) * 1.5 if rental.days_rented > 2
63
- when Movie::NEW_RELEASE
64
- result += rental.days_rented * 3
65
- when Movie::CHILDRENS
66
- result += 1.5
67
- result += (rental.days_rented - 3) * 1.5 if rental.days_rented > 3
68
- end
69
- result
73
+ rental.charge
74
75
76
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments