Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
21
Task/Inheritance-Multiple/Wren/inheritance-multiple.wren
Normal file
21
Task/Inheritance-Multiple/Wren/inheritance-multiple.wren
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
class Camera {
|
||||
construct new() {}
|
||||
snap() { System.print("taking a photo") }
|
||||
}
|
||||
|
||||
class Phone {
|
||||
construct new() {}
|
||||
call() { System.print("calling home") }
|
||||
}
|
||||
|
||||
class CameraPhone is Camera {
|
||||
construct new(phone) { _phone = phone } // uses composition for the Phone part
|
||||
// inherits Camera's snap() method
|
||||
// Phone's call() method can be wrapped
|
||||
call() { _phone.call() }
|
||||
}
|
||||
|
||||
var p = Phone.new()
|
||||
var cp = CameraPhone.new(p)
|
||||
cp.snap()
|
||||
cp.call()
|
||||
Loading…
Add table
Add a link
Reference in a new issue