Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
5
Task/Abstract-type/Lingo/abstract-type-1.lingo
Normal file
5
Task/Abstract-type/Lingo/abstract-type-1.lingo
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
on extendAbstractClass (instance, abstractClass)
|
||||
-- 'raw' instance of abstract class is made parent ("ancestor") of the
|
||||
-- passed instance, i.e. the passed instance extends the abstract class
|
||||
instance.setProp(#ancestor, abstractClass.rawNew())
|
||||
end
|
||||
12
Task/Abstract-type/Lingo/abstract-type-2.lingo
Normal file
12
Task/Abstract-type/Lingo/abstract-type-2.lingo
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- instantiation of abstract class by calling its constructor fails
|
||||
on new (me)
|
||||
-- optional: show error message as alert
|
||||
_player.alert("Error:"&&me.script&&" is an abstract class")
|
||||
return VOID
|
||||
end
|
||||
|
||||
on ring (me, n)
|
||||
repeat with i = 1 to n
|
||||
put me.ringtone
|
||||
end repeat
|
||||
end
|
||||
11
Task/Abstract-type/Lingo/abstract-type-3.lingo
Normal file
11
Task/Abstract-type/Lingo/abstract-type-3.lingo
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
property ringtone
|
||||
|
||||
on new (me)
|
||||
extendAbstractClass(me, script("AbstractClass"))
|
||||
me.ringtone = "Bell"
|
||||
return me
|
||||
end
|
||||
|
||||
on foo (me)
|
||||
put "FOO"
|
||||
end
|
||||
10
Task/Abstract-type/Lingo/abstract-type-4.lingo
Normal file
10
Task/Abstract-type/Lingo/abstract-type-4.lingo
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
obj = script("MyClass").new()
|
||||
obj.ring(3)
|
||||
-- "Bell"
|
||||
-- "Bell"
|
||||
-- "Bell"
|
||||
|
||||
-- this fails
|
||||
test = script("AbstractClass").new()
|
||||
put test
|
||||
-- <Void>
|
||||
12
Task/Abstract-type/Lingo/abstract-type-5.lingo
Normal file
12
Task/Abstract-type/Lingo/abstract-type-5.lingo
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
on implementsInterface (instance, interfaceClass)
|
||||
interfaceFuncs = interfaceClass.handlers()
|
||||
funcs = instance.handlers()
|
||||
repeat with f in interfaceFuncs
|
||||
if funcs.getPos(f)=0 then
|
||||
-- optional: show error message as alert
|
||||
_player.alert("Error:"&&instance.script&&"doesn't implement interface"&&interfaceClass)
|
||||
return FALSE
|
||||
end if
|
||||
end repeat
|
||||
return TRUE
|
||||
end
|
||||
3
Task/Abstract-type/Lingo/abstract-type-6.lingo
Normal file
3
Task/Abstract-type/Lingo/abstract-type-6.lingo
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
on foo
|
||||
on bar
|
||||
on foobar
|
||||
20
Task/Abstract-type/Lingo/abstract-type-7.lingo
Normal file
20
Task/Abstract-type/Lingo/abstract-type-7.lingo
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
on new (me)
|
||||
-- if this class doesn't implement all functions of the
|
||||
-- interface class, instantiation fails
|
||||
if not implementsInterface(me, script("InterfaceClass")) then
|
||||
return VOID
|
||||
end if
|
||||
return me
|
||||
end
|
||||
|
||||
on foo (me)
|
||||
put "FOO"
|
||||
end
|
||||
|
||||
on bar (me)
|
||||
put "BAR"
|
||||
end
|
||||
|
||||
on foobar (me)
|
||||
put "FOOBAR"
|
||||
end
|
||||
3
Task/Abstract-type/Lingo/abstract-type-8.lingo
Normal file
3
Task/Abstract-type/Lingo/abstract-type-8.lingo
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
obj = script("MyClass").new()
|
||||
put obj -- would show <Void> if interface is not fully implemented
|
||||
-- <offspring "MyClass" 2 171868>
|
||||
Loading…
Add table
Add a link
Reference in a new issue