@@ -286,7 +286,7 @@ interface Drawable {
286
286
```
287
287
288
288
You create a class called ` Circle ` which implements the ` Drawable ` interface and provides implementations for all of
289
- its member functions :
289
+ its members :
290
290
291
291
``` kotlin
292
292
class Circle : Drawable {
@@ -297,6 +297,7 @@ class Circle : Drawable {
297
297
override fun resize () {
298
298
TODO (" An example implementation" )
299
299
}
300
+ override val color = null
300
301
}
301
302
```
302
303
@@ -328,7 +329,7 @@ you can create an instance of the `Circle` class and delegate the implementation
328
329
class to this instance. To do this, use the ` by ` keyword. For example:
329
330
330
331
``` kotlin
331
- class RedCircle (param : Circle ) : Circle by param
332
+ class RedCircle (param : Circle ) : Drawable by param
332
333
```
333
334
334
335
Here, ` param ` is the name of the instance of the ` Circle ` class that the implementations of member functions are delegated to.
@@ -340,7 +341,7 @@ you add code only for the behavior you want to change for your child class.
340
341
For example, if you want to change the value of the ` color ` property:
341
342
342
343
``` kotlin
343
- class RedCircle (param : Circle ) : Circle by param {
344
+ class RedCircle (param : Circle ) : Drawable by param {
344
345
// No boilerplate code!
345
346
override val color = " red"
346
347
}
@@ -670,7 +671,7 @@ class BasicMessenger : Messenger {
670
671
}
671
672
}
672
673
673
- class SmartMessenger (private val basicMessenger : BasicMessenger ) : Messenger by basicMessenger {
674
+ class SmartMessenger (val basicMessenger : BasicMessenger ) : Messenger by basicMessenger {
674
675
override fun sendMessage (message : String ) {
675
676
println (" Sending a smart message: $message " )
676
677
basicMessenger.sendMessage(" [smart] $message " )
0 commit comments