Skip to content

Commit 29eed76

Browse files
committed
ch01: ComedyCalculator에서 오버라이딩해서 쓰도록 유도
1 parent c54ccb9 commit 29eed76

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/main/kotlin/chapter01/CreateStatementData.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ open class PerformanceCalculator {
3434
}
3535

3636
"comedy" -> {
37-
result = 30000
38-
if (this.aPerformance.audience > 20) {
39-
result += 10000 + 500 * (this.aPerformance.audience - 20)
40-
}
41-
result += 300 * this.aPerformance.audience
37+
throw Error("오류 발생")
4238
}
4339

4440
else -> {
@@ -75,6 +71,16 @@ class TragedyCalculator : PerformanceCalculator {
7571
}
7672

7773
class ComedyCalculator : PerformanceCalculator {
74+
override val amount: Int
75+
get() {
76+
var result = 30000
77+
if (this.aPerformance.audience > 20) {
78+
result += 10000 + 500 * (this.aPerformance.audience - 20)
79+
}
80+
result += 300 * this.aPerformance.audience
81+
return result
82+
}
83+
7884
constructor(aPerformance: Performance, aPlay: Play) : super(aPerformance, aPlay)
7985
}
8086

0 commit comments

Comments
 (0)