Page 1 of 1

3.10 OOP try

Posted: Thu Oct 24, 2019 1:04 pm
by bluatigro
i was trying some stuf in OOP

how do i do this good

Code: Select all

new a as class 1 , 2 , 3
new b as class 4 , 5 , 6


''new c as class::add b::x , b::y , b::z
print c
end
class v3d
  dim x , y , z
  sub class
    call v3d::class 0 , 0 , 0
  end sub
  sub class a , b , c
    x = a
    y = b
    z = c
  end sub
  function add( a , b , c )
    x = x + a
    y = y + b
    z = z + c
    new add as v3d::class x , y , z 
  end function
end class

Re: 3.10 OOP try

Posted: Thu Oct 24, 2019 2:16 pm
by guest
bluatigro wrote: Thu Oct 24, 2019 1:04 pmhow do i do this
This works:

Code: Select all

new a as v3d 1, 2, 3
new b as v3d 4, 5, 6

call a::add 7, 8, 9
call b::add 10, 11, 12

call a::get d, e, f
call b::get g, h, i

discard a
discard b

print d, e, f
print g, h, i
end

class v3d
  dim x , y , z
  
  sub v3d
    x = 0
    y = 0
    z = 0
  end sub
  
  sub v3d a , b , c
    x = a
    y = b
    z = c
  end sub
  
  sub add a , b , c
    x += a
    y += b
    z += c
  end sub
  
  sub get byref a, byref b, byref c
    a = x
    b = y
    c = z
  end sub

end class