Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue