Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
30
Task/Inheritance-Multiple/Forth/inheritance-multiple.fth
Normal file
30
Task/Inheritance-Multiple/Forth/inheritance-multiple.fth
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
\ define class camera with method say:
|
||||
:class camera
|
||||
:m say: ." camera " ;m
|
||||
;class
|
||||
|
||||
\ define class phone with method say:
|
||||
:class phone
|
||||
:m say: ." phone " ;m
|
||||
;class
|
||||
|
||||
\ define cameraPhone phone with method say:
|
||||
\ class cameraPhone inherits from both class
|
||||
\ camera and class phone
|
||||
:class cameraPhone super{ camera phone }
|
||||
:m say: self say: \ method conflicts in superclasses
|
||||
\ are resolved by left-to-right order
|
||||
\ so self say: will call the say: method
|
||||
\ from class camera
|
||||
super> phone say: \ super> phone is used to direct
|
||||
\ this say: method to use the
|
||||
\ method from class phone
|
||||
;m
|
||||
;class
|
||||
|
||||
cameraPhone cp \ instantiate a cameraPhone object named cp
|
||||
|
||||
cp say: \ send the say: message to cp
|
||||
|
||||
\ output:
|
||||
camera phone
|
||||
Loading…
Add table
Add a link
Reference in a new issue