diff --git a/chapter1/Customer.rb b/chapter1/Customer.rb index eb73bcd..6a924c8 100644 --- a/chapter1/Customer.rb +++ b/chapter1/Customer.rb @@ -27,6 +27,20 @@ def statement print @result end + def html_statement + result ="

Rentals for #{@name}

\n" + @rentals.each do |element| + # このレンタル料金を表示 + result += "\t" + element.movie.title+": " + element.charge.to_s + "
\n" + end + # フッターを追加 + result += "

You owe #{total_charge}

\n" + result += "On this rental you earned " + + "#{total_frequent_renter_points} " + + "frequent renter points

" + result + end + private def total_charge diff --git a/chapter1/TC_Customer.rb b/chapter1/TC_Customer.rb index 9b50c35..81ae9e8 100644 --- a/chapter1/TC_Customer.rb +++ b/chapter1/TC_Customer.rb @@ -29,4 +29,11 @@ def setup result= "Rental Record for kono\n\tStar Wars\t9.5\n\tDistrict 9\t6\n\tPonyo\t4.5\nAmount owed is 20.0\nYou earned 4 frequent renter points" assert_equal(result, @obj.result) end + must "test2" do + @obj.add_rental(Rental.new(@movie1, 10)) + @obj.add_rental(Rental.new(@movie2, 15)) + @obj.add_rental(Rental.new(@movie3, 20)) + result="

Rentals for kono

\n\tStar Wars: 14.0
\n\tDistrict 9: 45
\n\tPonyo: 27.0
\n

You owe 86.0

\nOn this rental you earned 4 frequent renter points

" + assert_equal(result, @obj.html_statement) + end end