Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
20
Task/Compound-data-type/Fantom/compound-data-type.fantom
Normal file
20
Task/Compound-data-type/Fantom/compound-data-type.fantom
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// define a class to contain the two fields
|
||||
// accessors to get/set the field values are automatically generated
|
||||
class Point
|
||||
{
|
||||
Int x
|
||||
Int y
|
||||
}
|
||||
|
||||
class Main
|
||||
{
|
||||
public static Void main ()
|
||||
{
|
||||
// empty constructor, so x,y set to 0
|
||||
point1 := Point()
|
||||
// constructor uses with-block, to initialise values
|
||||
point2 := Point { x = 1; y = 2}
|
||||
echo ("Point 1 = (" + point1.x + ", " + point1.y + ")")
|
||||
echo ("Point 2 = (" + point2.x + ", " + point2.y + ")")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue