langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
|
|
@ -0,0 +1,4 @@
|
|||
class camera =
|
||||
object (self)
|
||||
(*functions go here...*)
|
||||
end
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
class mobile_phone =
|
||||
object (self)
|
||||
(*functions go here...*)
|
||||
end
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
class camera_phone =
|
||||
object (self)
|
||||
inherit camera
|
||||
inherit mobile_phone
|
||||
(*functions go here...*)
|
||||
end
|
||||
53
Task/Inheritance-Multiple/Objective-C/inheritance-multiple.m
Normal file
53
Task/Inheritance-Multiple/Objective-C/inheritance-multiple.m
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
@interface Camera : NSObject {
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation Camera
|
||||
@end
|
||||
|
||||
@interface MobilePhone : NSObject {
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation MobilePhone
|
||||
@end
|
||||
|
||||
@interface CameraPhone : NSObject {
|
||||
Camera *camera;
|
||||
MobilePhone *phone;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation CameraPhone
|
||||
|
||||
-(id)init {
|
||||
if ((self = [super init])) {
|
||||
camera = [[Camera alloc] init];
|
||||
phone = [[MobilePhone alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)dealloc {
|
||||
[camera release];
|
||||
[phone release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(void)forwardInvocation:(NSInvocation *)anInvocation {
|
||||
SEL aSelector = [anInvocation selector];
|
||||
if ([camera respondsToSelector:aSelector])
|
||||
[anInvocation invokeWithTarget:camera];
|
||||
else if ([phone respondsToSelector:aSelector])
|
||||
[anInvocation invokeWithTarget:phone];
|
||||
else
|
||||
[self doesNotRecognizeSelector:aSelector];
|
||||
}
|
||||
|
||||
-(BOOL)respondsToSelector:(SEL)aSelector {
|
||||
return [camera respondsToSelector:aSelector]
|
||||
|| [phone respondsToSelector:aSelector]
|
||||
|| [super respondsToSelector:aSelector];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
class Camera
|
||||
string cbuf
|
||||
method TakePhoto()
|
||||
end method
|
||||
method ViewPhoto()
|
||||
end method
|
||||
end class
|
||||
|
||||
class MobilePhone
|
||||
string pbuf
|
||||
method MakeCall()
|
||||
end method
|
||||
method TakeCall()
|
||||
end method
|
||||
end class
|
||||
|
||||
class CameraPhone
|
||||
has Camera,MobilePhone
|
||||
end class
|
||||
|
||||
CameraPhone cp
|
||||
|
||||
cp.ViewPhoto
|
||||
cp.MakeCall
|
||||
5
Task/Inheritance-Multiple/Oz/inheritance-multiple.oz
Normal file
5
Task/Inheritance-Multiple/Oz/inheritance-multiple.oz
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class Camera end
|
||||
|
||||
class MobilePhone end
|
||||
|
||||
class CameraPhone from Camera MobilePhone end
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
class Camera {}
|
||||
class MobilePhone {}
|
||||
class CameraPhone is Camera is MobilePhone {}
|
||||
|
||||
say CameraPhone.^mro; # undefined type object
|
||||
say CameraPhone.new.^mro; # instantiated object
|
||||
16
Task/Inheritance-Multiple/Pop11/inheritance-multiple.pop11
Normal file
16
Task/Inheritance-Multiple/Pop11/inheritance-multiple.pop11
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
;;; load object support
|
||||
lib objectclass;
|
||||
|
||||
define :class Camera;
|
||||
;;; slots go here
|
||||
enddefine;
|
||||
|
||||
define :class MobilePhone;
|
||||
;;; slots go here
|
||||
enddefine;
|
||||
|
||||
define :class CameraPhone is Camera, MobilePhone;
|
||||
;;; extra slots go here
|
||||
enddefine;
|
||||
|
||||
;;; methods go here
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
Class Camera
|
||||
EndClass
|
||||
|
||||
Class Mobil
|
||||
EndClass
|
||||
|
||||
Class CameraMobile Extends Camera Extends Mobil
|
||||
EndClass
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
define: #Camera.
|
||||
define: #MobilePhone.
|
||||
define: #CameraPhone &parents: {Camera. MobilePhone}.
|
||||
Loading…
Add table
Add a link
Reference in a new issue