-- Class of ParentClass
Animals = {x = 0, y = 0};
Animals.__index = Animals;
-- Constructor
function Animals:New(x, y)
local self = {};
setmetatable(self, Animals);
self.x = x;
self.y = y;
return self;
end
function Animals:Fly()
-- body
print("animal fly");
end
-- print(Animals:New(1, 5).x);
Duck = {z = 0};
setmetatable(Duck, Animals);
Duck.__index = Duck;
function Duck:New(x, y, z)
-- body
local self = {};
self = Animals:New(x, y);
setmetatable(self, Duck);
self.z = z;
return self;
end
-- function Duck:Fly()
-- -- body
-- print("duck fly");
-- end
function Cry( )
-- body
print("duck cry");
end
animal = Animals:New(1, 5);
duck = Duck:New(3, 88);
print(animal:Fly());
print(duck.Fly());