Inheritance/Multiple: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 1,211: Line 1,211:
;; implement methods here
;; implement methods here
))</lang>
))</lang>

=={{header|Ring}}==
<lang ring>
# Project : Inheritance/Multiple

mergemethods(:CameraPhone,:MobilePhone)

o1 = new CameraPhone
? o1
? o1.testCamera()
? o1.testMobilePhone()

func AddParentClassAttributes oObject,cClass
# Add Attributes
cCode = "oTempObject = new " + cClass
eval(cCode)
for cAttribute in Attributes(oTempObject)
AddAttribute(oObject,cAttribute)
cCode = "oObject." + cAttribute + " = oTempObject." + cAttribute
eval(cCode)
next

class Camera
Name = "Camera"
func testCamera
? "Message from testCamera"

class MobilePhone
Type = "Android"
func testMobilePhone
? "Message from MobilePhone"

class CameraPhone from Camera

# Add MobilePhone Attributes
AddParentClassAttributes(self,:MobilePhone)
</lang>
Output:
<pre>
name: Camera
type: Android
Message from testCamera
Message from MobilePhone
</pre>


=={{header|Ruby}}==
=={{header|Ruby}}==