2018-02-04 16:08:03 +01:00
|
|
|
function init_animal(byref self)
|
2018-02-05 19:21:27 +01:00
|
|
|
self.+yell:=@animal_yell;
|
2018-02-04 16:08:03 +01:00
|
|
|
endfunction
|
|
|
|
|
function animal_yell(byref self)
|
|
|
|
|
print(self.text.call(self));
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function init_cat()
|
|
|
|
|
var cat:=struct;
|
|
|
|
|
init_animal(cat);
|
2018-02-05 19:21:27 +01:00
|
|
|
cat.+text:=@cat_text;
|
2018-02-04 16:08:03 +01:00
|
|
|
return cat;
|
|
|
|
|
endfunction
|
|
|
|
|
function cat_text(byref self)
|
|
|
|
|
return "miau";
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function init_dog()
|
|
|
|
|
var dog:=struct;
|
|
|
|
|
init_animal(dog);
|
2018-02-05 19:21:27 +01:00
|
|
|
dog.+text:=@dog_text;
|
2018-02-04 16:08:03 +01:00
|
|
|
dog.+angry:=0;
|
|
|
|
|
return dog;
|
|
|
|
|
endfunction
|
|
|
|
|
function dog_text(byref self)
|
|
|
|
|
if (self.angry)
|
|
|
|
|
return "ggggrrr";
|
|
|
|
|
endif
|
|
|
|
|
return "wuff";
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
var dog:=init_dog();
|
|
|
|
|
dog.yell.call(dog);
|
|
|
|
|
dog.angry:=1;
|
|
|
|
|
dog.yell.call(dog);
|
|
|
|
|
|
|
|
|
|
var cat:=init_cat();
|
|
|
|
|
cat.yell.call(cat);
|