Skip to content

Commit abd0707

Browse files
committed
ch01: 장르마다 달라지는 부분을 필요할 때 오버라이드하도록 변경
1 parent dc29479 commit abd0707

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/main/kotlin/chapter01/CreateStatementData.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ open class PerformanceCalculator {
2929
get() {
3030
throw Error("서브클래스에서 처리하도록 설계되었습니다.")
3131
}
32-
val volumeCredits: Int
32+
open val volumeCredits: Int
3333
get() {
34-
var result = maxOf(this.aPerformance.audience - 30, 0)
35-
if (this.play?.type == "comedy") result += this.aPerformance.audience / 5
36-
return result
34+
return maxOf(this.aPerformance.audience - 30, 0)
35+
// var result = maxOf(this.aPerformance.audience - 30, 0)
36+
// if (this.play?.type == "comedy") result += this.aPerformance.audience / 5
37+
// return result
3738
}
3839

3940
constructor(aPerformance: Performance, aPlay: Play) {
@@ -65,6 +66,10 @@ class ComedyCalculator : PerformanceCalculator {
6566
result += 300 * this.aPerformance.audience
6667
return result
6768
}
69+
override val volumeCredits: Int
70+
get() {
71+
return super.volumeCredits + this.aPerformance.audience / 5
72+
}
6873

6974
constructor(aPerformance: Performance, aPlay: Play) : super(aPerformance, aPlay)
7075
}

0 commit comments

Comments
 (0)