June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
46
Task/Polymorphism/Elena/polymorphism.elena
Normal file
46
Task/Polymorphism/Elena/polymorphism.elena
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import extensions.
|
||||
|
||||
class Point
|
||||
{
|
||||
int prop X :: _x.
|
||||
int prop Y :: _y.
|
||||
|
||||
constructor new(IntNumber x, IntNumber y)
|
||||
[
|
||||
_x := x.
|
||||
_y := y.
|
||||
]
|
||||
|
||||
constructor new
|
||||
<= new(0,0).
|
||||
|
||||
print [ console printLine("Point") ]
|
||||
}
|
||||
|
||||
class Circle :: Point
|
||||
{
|
||||
int prop R :: _r.
|
||||
|
||||
constructor new
|
||||
<= new(0).
|
||||
|
||||
constructor new(IntNumber r)
|
||||
<= new(0, 0, r).
|
||||
|
||||
constructor new(IntNumber x, IntNumber y, IntNumber r)
|
||||
<= new(x, y);
|
||||
[
|
||||
_r := r.
|
||||
]
|
||||
|
||||
print [ console printLine("Circle") ]
|
||||
}
|
||||
|
||||
program =
|
||||
[
|
||||
var p := Point new.
|
||||
var c := Circle new.
|
||||
|
||||
p print.
|
||||
c print.
|
||||
].
|
||||
Loading…
Add table
Add a link
Reference in a new issue