@@ -57,32 +57,6 @@ fun statement(invoice: Invoice, plays: Plays): String {
5757}
5858
5959private fun renderPlainText (data : StatementData , plays : Plays ): String {
60- fun amountFor (aPerformance : EnrichedPerformance ): Int {
61- var result = 0
62- when (aPerformance.play.type) {
63- " tragedy" -> {
64- result = 40000
65- if (aPerformance.audience > 30 ) {
66- result + = 1000 * (aPerformance.audience - 30 )
67- }
68- }
69-
70- " comedy" -> {
71- result = 30000
72- if (aPerformance.audience > 20 ) {
73- result + = 10000 + 500 * (aPerformance.audience - 20 )
74- }
75- result + = 300 * aPerformance.audience
76- }
77-
78- else -> {
79- throw Error (" 알 수 없는 장르: ${aPerformance.play.type} " )
80- }
81- }
82-
83- return result
84- }
85-
8660 fun volumeCreditsFor (aPerformance : EnrichedPerformance ): Int {
8761 var result = maxOf(aPerformance.audience - 30 , 0 )
8862 if (aPerformance.play.type == " comedy" ) result + = aPerformance.audience / 5
@@ -104,15 +78,15 @@ private fun renderPlainText(data: StatementData, plays: Plays): String {
10478 fun totalAmount (): Int {
10579 var result = 0
10680 for (perf in data.performances) {
107- result + = amountFor( perf)
81+ result + = perf.amount
10882 }
10983 return result
11084 }
11185
11286 var result = " 청구 내역 (고객명: ${data.customer} )\n "
11387 for (perf in data.performances) {
11488 // 청구 내역을 출력한다.
115- result + = " ${perf.play.name} : ${usd(amountFor( perf) )} (${perf.audience} 석)\n "
89+ result + = " ${perf.play.name} : ${usd(perf.amount )} (${perf.audience} 석)\n "
11690 }
11791 result + = " 총액: ${usd(totalAmount())} \n "
11892 result + = " 적립 포인트: ${totalVolumeCredits()} 점"
0 commit comments