Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
13
Task/Inheritance-Single/Ada/inheritance-single.adb
Normal file
13
Task/Inheritance-Single/Ada/inheritance-single.adb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package Inheritance is
|
||||
type Animal is tagged private;
|
||||
type Dog is new Animal with private;
|
||||
type Cat is new Animal with private;
|
||||
type Lab is new Dog with private;
|
||||
type Collie is new Dog with private;
|
||||
private
|
||||
type Animal is tagged null record;
|
||||
type Dog is new Animal with null record;
|
||||
type Cat is new Animal with null record;
|
||||
type Lab is new Dog with null record;
|
||||
type Collie is new Dog with null record;
|
||||
end Inheritance;
|
||||
48
Task/Inheritance-Single/COBOL/inheritance-single.cob
Normal file
48
Task/Inheritance-Single/COBOL/inheritance-single.cob
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
CLASS-ID. Animal.
|
||||
*> ...
|
||||
END CLASS Animal.
|
||||
|
||||
IDENTIFICATION DIVISION.
|
||||
CLASS-ID. Dog
|
||||
INHERITS FROM Animal.
|
||||
ENVIRONMENT DIVISION.
|
||||
CONFIGURATION SECTION.
|
||||
REPOSITORY.
|
||||
CLASS Animal.
|
||||
|
||||
*> ...
|
||||
END CLASS Dog.
|
||||
|
||||
IDENTIFICATION DIVISION.
|
||||
CLASS-ID. Cat
|
||||
INHERITS FROM Animal.
|
||||
ENVIRONMENT DIVISION.
|
||||
CONFIGURATION SECTION.
|
||||
REPOSITORY.
|
||||
CLASS Animal.
|
||||
|
||||
*> ...
|
||||
END CLASS Cat.
|
||||
|
||||
IDENTIFICATION DIVISION.
|
||||
CLASS-ID. Lab
|
||||
INHERITS FROM Dog.
|
||||
ENVIRONMENT DIVISION.
|
||||
CONFIGURATION SECTION.
|
||||
REPOSITORY.
|
||||
CLASS Dog.
|
||||
|
||||
*> ...
|
||||
END CLASS Lab.
|
||||
|
||||
IDENTIFICATION DIVISION.
|
||||
CLASS-ID. Collie
|
||||
INHERITS FROM Dog.
|
||||
ENVIRONMENT DIVISION.
|
||||
CONFIGURATION SECTION.
|
||||
REPOSITORY.
|
||||
CLASS Dog.
|
||||
|
||||
*> ...
|
||||
END CLASS Collie.
|
||||
15
Task/Inheritance-Single/Haxe/inheritance-single-1.hx
Normal file
15
Task/Inheritance-Single/Haxe/inheritance-single-1.hx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
class Animal {
|
||||
// ...
|
||||
}
|
||||
class Cat extends Animal {
|
||||
// ...
|
||||
}
|
||||
class Dog extends Animal {
|
||||
// ...
|
||||
}
|
||||
class Lab extends Dog {
|
||||
// ...
|
||||
}
|
||||
class Collie extends Dog {
|
||||
// ...
|
||||
}
|
||||
14
Task/Inheritance-Single/Haxe/inheritance-single-2.hx
Normal file
14
Task/Inheritance-Single/Haxe/inheritance-single-2.hx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
class Animal ()
|
||||
end
|
||||
|
||||
class Dog : Animal ()
|
||||
end
|
||||
|
||||
class Cat : Animal ()
|
||||
end
|
||||
|
||||
class Lab : Dog ()
|
||||
end
|
||||
|
||||
class Collie : Dog ()
|
||||
end
|
||||
30
Task/Inheritance-Single/Pluto/inheritance-single.pluto
Normal file
30
Task/Inheritance-Single/Pluto/inheritance-single.pluto
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
class Animal end
|
||||
|
||||
class Dog extends Animal
|
||||
function type() return "Dog" end
|
||||
end
|
||||
|
||||
class Cat extends Animal
|
||||
function type() return "Cat" end
|
||||
end
|
||||
|
||||
class Labrador extends Dog
|
||||
function type() return "Labrador" end
|
||||
end
|
||||
|
||||
class Collie extends Dog
|
||||
function type() return "Collie" end
|
||||
end
|
||||
|
||||
local animals = {new Dog(), new Cat(), new Labrador(), new Collie()}
|
||||
for animals as a do
|
||||
print($"{a:type()} is an Animal = {a instanceof Animal}")
|
||||
end
|
||||
print()
|
||||
for animals as a do
|
||||
print($"{a:type()} is a Dog = {a instanceof Dog}")
|
||||
end
|
||||
print()
|
||||
for animals as a do
|
||||
print($"{a:type()} is a Cat = {a instanceof Cat}")
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
class Animal {}
|
||||
class Dog : Animal {}
|
||||
class Cat: Animal {}
|
||||
class Lab : Dog {}
|
||||
class Collie : Dog {}
|
||||
26
Task/Inheritance-Single/Rebol/inheritance-single.rebol
Normal file
26
Task/Inheritance-Single/Rebol/inheritance-single.rebol
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Rebol [
|
||||
Title: "Inheritance"
|
||||
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]
|
||||
Loading…
Add table
Add a link
Reference in a new issue