tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
56
Task/Polymorphism/OxygenBasic/polymorphism.oxy
Normal file
56
Task/Polymorphism/OxygenBasic/polymorphism.oxy
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
type tpoint float xx,yy
|
||||
type tcircle float xx,yy,rr
|
||||
|
||||
'==========
|
||||
class point
|
||||
'==========
|
||||
'
|
||||
has tpoint
|
||||
'
|
||||
method constructor (float x=0,y=0){this<=x,y}
|
||||
method destructor {}
|
||||
method V() as point {return @this}
|
||||
method V(tpoint*a) {this<=a.xx,a.yy}
|
||||
method V(point *a) {this<=a.xx,a.yy}
|
||||
method X() as float {return xx}
|
||||
method Y() as float {return yy}
|
||||
method X(float a) {xx=a}
|
||||
method Y(float a) {yy=a}
|
||||
method clear() {this<=.0,.0}
|
||||
method show() as string {return "x=" xx ", y=" yy }
|
||||
'
|
||||
end class
|
||||
|
||||
|
||||
'===========
|
||||
class circle
|
||||
'===========
|
||||
'
|
||||
has point
|
||||
float rr
|
||||
'
|
||||
method constructor (float x=.0,y=.0,r=1.0){this<=x,y,r}
|
||||
method V(tcircle*a) {this<=a.xx,a.yy,a.rr}
|
||||
method V(circle *a) {this<=a.xx,a.yy,a.rr}
|
||||
method R() as float {return rr}
|
||||
method R(float a) {rr=a}
|
||||
method clear() {this<=.0,.0,.0}
|
||||
method show() as string {return "x=" xx ", y=" yy ", r=" rr }
|
||||
'
|
||||
end class
|
||||
|
||||
'=====
|
||||
'TESTS
|
||||
'=====
|
||||
|
||||
new circle ca (r=.5)
|
||||
new circle cb (x=10,y=10)
|
||||
new circle cc (10,10,0.5)
|
||||
|
||||
cb.r="7.5" 'will convert a string value
|
||||
|
||||
cb.y=20
|
||||
|
||||
print cb.show 'result x=10, y=20 ,r=7.5
|
||||
|
||||
del ca : del cb : del cc
|
||||
Loading…
Add table
Add a link
Reference in a new issue