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
14
Task/Polymorphism/Oforth/polymorphism-1.oforth
Normal file
14
Task/Polymorphism/Oforth/polymorphism-1.oforth
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Object Class new: Point(x, y)
|
||||
Point method: initialize(x, y) x := x y := y ;
|
||||
Point method: _x @x ;
|
||||
Point method: _y @y ;
|
||||
Point method: << "(" << @x << ", " << @y << ")" << ;
|
||||
|
||||
Object Class new: Circle(x, y, r)
|
||||
Circle method: initialize(x, y, r) x := x y := y r := r ;
|
||||
Circle method: _x @x ;
|
||||
Circle method: _y @y ;
|
||||
Circle method: _r @r ;
|
||||
Circle method: << "(" << @x << ", " << @y << ", " << @r << ")" << ;
|
||||
|
||||
Circle classMethod: newFromPoint(aPoint, r) self new(aPoint _x, aPoint _y, r) ;
|
||||
9
Task/Polymorphism/Oforth/polymorphism-2.oforth
Normal file
9
Task/Polymorphism/Oforth/polymorphism-2.oforth
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
: testPoly
|
||||
| p c |
|
||||
Point new(3, 4) ->p
|
||||
p println
|
||||
System.Out "Attributes of this point are : " << p _x << " and " << p _y << cr
|
||||
Circle new(5, 6, 7.1) ->c
|
||||
c println
|
||||
System.Out "Attributes of this circle are : " << c _x << ", " << c _y << " and " << c _r << cr
|
||||
Circle newFromPoint(p, 2) println ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue