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
|
|
@ -0,0 +1,18 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
' FB does not currently support multiple inheritance. Composition has to be used instead if one wants
|
||||
' to (effectively) inherit from more than one class. In some cases, this might arguably be a better
|
||||
' solution anyway.
|
||||
|
||||
Type Camera Extends Object ' if virtual methods etc needed
|
||||
' ...
|
||||
End Type
|
||||
|
||||
Type Phone Extends Object
|
||||
' ...
|
||||
End Type
|
||||
|
||||
Type CameraPhone Extends Phone ' single inheritance
|
||||
cam As Camera ' using composition here
|
||||
' other stuff
|
||||
End Type
|
||||
37
Task/Inheritance-Multiple/Lasso/inheritance-multiple.lasso
Normal file
37
Task/Inheritance-Multiple/Lasso/inheritance-multiple.lasso
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
define trait_camera => trait {
|
||||
require zoomfactor
|
||||
|
||||
provide has_zoom() => {
|
||||
return .zoomfactor > 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
define trait_mobilephone => trait {
|
||||
require brand
|
||||
|
||||
provide is_smart() => {
|
||||
return .brand == 'Apple'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
define cameraphone => type {
|
||||
|
||||
trait {
|
||||
import trait_camera, trait_mobilephone
|
||||
}
|
||||
|
||||
data public zoomfactor::integer = 0,
|
||||
public brand::string
|
||||
|
||||
}
|
||||
|
||||
local(mydevice = cameraphone)
|
||||
|
||||
#mydevice -> brand = 'Apple'
|
||||
#mydevice -> zoomfactor = 0
|
||||
|
||||
#mydevice -> has_zoom
|
||||
'<br />'
|
||||
#mydevice -> is_smart
|
||||
11
Task/Inheritance-Multiple/Lingo/inheritance-multiple-1.lingo
Normal file
11
Task/Inheritance-Multiple/Lingo/inheritance-multiple-1.lingo
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
-- parent script "Camera"
|
||||
property resolution
|
||||
|
||||
on new (me)
|
||||
me.resolution = "1024x768"
|
||||
return me
|
||||
end
|
||||
|
||||
on snap (me)
|
||||
put "SNAP!"
|
||||
end
|
||||
13
Task/Inheritance-Multiple/Lingo/inheritance-multiple-2.lingo
Normal file
13
Task/Inheritance-Multiple/Lingo/inheritance-multiple-2.lingo
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
-- parent script "MobilePhone"
|
||||
property ringtone
|
||||
|
||||
on new (me)
|
||||
me.ringtone = "Bell"
|
||||
return me
|
||||
end
|
||||
|
||||
on ring (me, n)
|
||||
repeat with i = 1 to n
|
||||
put "RING!!!"
|
||||
end repeat
|
||||
end
|
||||
15
Task/Inheritance-Multiple/Lingo/inheritance-multiple-3.lingo
Normal file
15
Task/Inheritance-Multiple/Lingo/inheritance-multiple-3.lingo
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
-- parent script "CameraPhone"
|
||||
property ancestor
|
||||
|
||||
on new (me)
|
||||
c = script("Camera").new()
|
||||
mp = script("MobilePhone").new()
|
||||
|
||||
-- make the Camera instance a parent of the MobilePhone instance
|
||||
mp.setProp(#ancestor, c)
|
||||
|
||||
-- make the MobilePhone instance a parent of this CameraPhone instance
|
||||
me.ancestor = mp
|
||||
|
||||
return me
|
||||
end
|
||||
15
Task/Inheritance-Multiple/Lingo/inheritance-multiple-4.lingo
Normal file
15
Task/Inheritance-Multiple/Lingo/inheritance-multiple-4.lingo
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
cp = script("CameraPhone").new()
|
||||
|
||||
cp.snap()
|
||||
-- "SNAP!"
|
||||
|
||||
cp.ring(3)
|
||||
-- "RING!!!"
|
||||
-- "RING!!!"
|
||||
-- "RING!!!"
|
||||
|
||||
put cp.resolution
|
||||
-- "1024x768"
|
||||
|
||||
put cp.ringtone
|
||||
-- "Bell"
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
Property new: Camera
|
||||
Property new: MobilePhone
|
||||
|
||||
Object Class new: CameraPhone
|
||||
CameraPhone is: Camera
|
||||
CameraPhone is: MobilePhone
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
class Camera {};
|
||||
class MobilePhone {};
|
||||
class CameraPhone << Camera, MobilePhone {};
|
||||
11
Task/Inheritance-Multiple/Swift/inheritance-multiple.swift
Normal file
11
Task/Inheritance-Multiple/Swift/inheritance-multiple.swift
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
protocol Camera {
|
||||
|
||||
}
|
||||
|
||||
protocol Phone {
|
||||
|
||||
}
|
||||
|
||||
class CameraPhone: Camera, Phone {
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue