langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
4
Task/Inheritance-Single/OCaml/inheritance-single-1.ocaml
Normal file
4
Task/Inheritance-Single/OCaml/inheritance-single-1.ocaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
class animal =
|
||||
object (self)
|
||||
(*functions go here...*)
|
||||
end
|
||||
5
Task/Inheritance-Single/OCaml/inheritance-single-2.ocaml
Normal file
5
Task/Inheritance-Single/OCaml/inheritance-single-2.ocaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class dog =
|
||||
object (self)
|
||||
inherit animal
|
||||
(*functions go here...*)
|
||||
end
|
||||
5
Task/Inheritance-Single/OCaml/inheritance-single-3.ocaml
Normal file
5
Task/Inheritance-Single/OCaml/inheritance-single-3.ocaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class cat =
|
||||
object (self)
|
||||
inherit animal
|
||||
(*functions go here...*)
|
||||
end
|
||||
5
Task/Inheritance-Single/OCaml/inheritance-single-4.ocaml
Normal file
5
Task/Inheritance-Single/OCaml/inheritance-single-4.ocaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class lab =
|
||||
object (self)
|
||||
inherit dog
|
||||
(*functions go here...*)
|
||||
end
|
||||
5
Task/Inheritance-Single/OCaml/inheritance-single-5.ocaml
Normal file
5
Task/Inheritance-Single/OCaml/inheritance-single-5.ocaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class collie =
|
||||
object (self)
|
||||
inherit dog
|
||||
(*functions go here...*)
|
||||
end
|
||||
14
Task/Inheritance-Single/Objeck/inheritance-single.objeck
Normal file
14
Task/Inheritance-Single/Objeck/inheritance-single.objeck
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
class Animal
|
||||
{ #~ ... ~# }
|
||||
|
||||
class Dog from Animal
|
||||
{ #~ ... ~# }
|
||||
|
||||
class Lab from Dog
|
||||
{ #~ ... ~# }
|
||||
|
||||
class Collie from Dog
|
||||
{ #~ ... ~# }
|
||||
|
||||
class Cat from Animal
|
||||
{ #~ ... ~# }
|
||||
34
Task/Inheritance-Single/Objective-C/inheritance-single.m
Normal file
34
Task/Inheritance-Single/Objective-C/inheritance-single.m
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
@interface Animal : NSObject
|
||||
{
|
||||
// ...
|
||||
}
|
||||
// ...
|
||||
@end
|
||||
|
||||
@interface Dog : Animal
|
||||
{
|
||||
// ...
|
||||
}
|
||||
// ...
|
||||
@end
|
||||
|
||||
@interface Lab : Dog
|
||||
{
|
||||
// ...
|
||||
}
|
||||
// ...
|
||||
@end
|
||||
|
||||
@interface Collie : Dog
|
||||
{
|
||||
// ...
|
||||
}
|
||||
// ...
|
||||
@end
|
||||
|
||||
@interface Cat : Animal
|
||||
{
|
||||
// ...
|
||||
}
|
||||
// ...
|
||||
@end
|
||||
37
Task/Inheritance-Single/OxygenBasic/inheritance-single.oxy
Normal file
37
Task/Inheritance-Single/OxygenBasic/inheritance-single.oxy
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
class animal
|
||||
method show() as string
|
||||
return "Animal "
|
||||
end method
|
||||
end Class
|
||||
|
||||
class dog
|
||||
from Animal Animal
|
||||
method show() as string
|
||||
return animal.show()+"dog "
|
||||
end method
|
||||
end Class
|
||||
|
||||
class cat
|
||||
from animal animal
|
||||
method show() as string
|
||||
return animal.show()+"cat "
|
||||
end method
|
||||
end Class
|
||||
|
||||
class Lab
|
||||
from dog dog
|
||||
method show() as string
|
||||
return dog.show()+"Lab "
|
||||
end method
|
||||
end Class
|
||||
|
||||
class Collie
|
||||
from dog dog
|
||||
method show() as string
|
||||
return dog.show()+"Collie "
|
||||
end method
|
||||
end Class
|
||||
|
||||
|
||||
Collie c
|
||||
print c.show 'result: Animal Dog Collie
|
||||
19
Task/Inheritance-Single/Oz/inheritance-single.oz
Normal file
19
Task/Inheritance-Single/Oz/inheritance-single.oz
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
class Animal
|
||||
%% ...
|
||||
end
|
||||
|
||||
class Dog from Animal
|
||||
%% ...
|
||||
end
|
||||
|
||||
class Lab from Dog
|
||||
%% ...
|
||||
end
|
||||
|
||||
class Collie from Dog
|
||||
%% ...
|
||||
end
|
||||
|
||||
class Cat from Animal
|
||||
%% ...
|
||||
end
|
||||
8
Task/Inheritance-Single/Perl-6/inheritance-single.pl6
Normal file
8
Task/Inheritance-Single/Perl-6/inheritance-single.pl6
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
class Animal {}
|
||||
class Dog is Animal {}
|
||||
class Cat is Animal {}
|
||||
class Lab is Dog {}
|
||||
class Collie is Dog {}
|
||||
|
||||
say ~Collie.^parents; # undefined type object
|
||||
say ~Collie.new.^parents; # instantiated object
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
Interface Animal
|
||||
Eat()
|
||||
Sleep()
|
||||
EndInterface
|
||||
|
||||
Interface Cat Extends Animal
|
||||
ChaseMouse()
|
||||
EndInterface
|
||||
|
||||
Interface Dog Extends Animal
|
||||
Bark()
|
||||
WagTail()
|
||||
EndInterface
|
||||
|
||||
Interface Lab Extends Dog
|
||||
Swim()
|
||||
EndInterface
|
||||
|
||||
Interface Collie Extends Dog
|
||||
HeardSheep()
|
||||
EndInterface
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
Class Animal
|
||||
EndClass
|
||||
|
||||
Class Dog Extends Animal
|
||||
Public Method Bark()
|
||||
EndMethod
|
||||
EndClass
|
||||
|
||||
Class Cat Extends Animal
|
||||
Public Method Sleep()
|
||||
EndMethod
|
||||
EndClass
|
||||
|
||||
Class Lab Extends Dog
|
||||
Public Method Swim()
|
||||
EndMethod
|
||||
EndClass
|
||||
|
||||
Class Collie Extends Dog
|
||||
Public Method Fetch()
|
||||
EndMethod
|
||||
EndClass
|
||||
|
||||
;- test the code
|
||||
*Lassie.Collie = NewObject.Collie
|
||||
*Lassie\Bark()
|
||||
*Lassie\Fetch()
|
||||
28
Task/Inheritance-Single/REBOL/inheritance-single.rebol
Normal file
28
Task/Inheritance-Single/REBOL/inheritance-single.rebol
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
REBOL [
|
||||
Title: "Inheritance"
|
||||
Author: oofoe
|
||||
Date: 2009-12-08
|
||||
URL: http://rosettacode.org/wiki/Inheritance
|
||||
]
|
||||
|
||||
; REBOL provides subclassing through its prototype mechanism:
|
||||
|
||||
Animal: make object! [
|
||||
legs: 4
|
||||
]
|
||||
|
||||
Dog: make Animal [
|
||||
says: "Woof!"
|
||||
]
|
||||
Cat: make Animal [
|
||||
says: "Meow..."
|
||||
]
|
||||
|
||||
Lab: make Dog []
|
||||
Collie: make Dog []
|
||||
|
||||
; Demonstrate inherited properties:
|
||||
|
||||
print ["Cat has" Cat/legs "legs."]
|
||||
|
||||
print ["Lab says:" Lab/says]
|
||||
5
Task/Inheritance-Single/Slate/inheritance-single.slate
Normal file
5
Task/Inheritance-Single/Slate/inheritance-single.slate
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
define: #Animal &parents: {Cloneable}.
|
||||
define: #Dog &parents: {Animal}.
|
||||
define: #Cat &parents: {Animal}.
|
||||
define: #Lab &parents: {Dog}.
|
||||
define: #Collie &parents: {Dog}.
|
||||
3
Task/Inheritance-Single/TXR/inheritance-single-1.txr
Normal file
3
Task/Inheritance-Single/TXR/inheritance-single-1.txr
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
@(defex cat animal)
|
||||
@(defex lab dog animal)
|
||||
@(defex collie dog)
|
||||
4
Task/Inheritance-Single/TXR/inheritance-single-2.txr
Normal file
4
Task/Inheritance-Single/TXR/inheritance-single-2.txr
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
@(try)
|
||||
@ (throw lab "x")
|
||||
@(catch animal (arg))
|
||||
@(end)
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
Class Animal
|
||||
' ...
|
||||
End Class
|
||||
|
||||
Class Dog
|
||||
Inherits Animal
|
||||
' ...
|
||||
End Class
|
||||
|
||||
Class Lab
|
||||
Inherits Dog
|
||||
' ...
|
||||
End Class
|
||||
|
||||
Class Collie
|
||||
Inherits Dog
|
||||
' ...
|
||||
End Class
|
||||
|
||||
Class Cat
|
||||
Inherits Animal
|
||||
' ...
|
||||
End Class
|
||||
5
Task/Inheritance-Single/Vorpal/inheritance-single.vorpal
Normal file
5
Task/Inheritance-Single/Vorpal/inheritance-single.vorpal
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
pet = new()
|
||||
cat = new(pet)
|
||||
dog = new(pet)
|
||||
fido = new(dog)
|
||||
felix = new(cat)
|
||||
Loading…
Add table
Add a link
Reference in a new issue