class Vector
attr_reader :X,:y
@@n = 0
def self.sum(*vecs)
x = y = 0
vecs.each{|v|x+=v.x;y+=v.y}
Vector.new(x,y)
end
def initialize(x,y)
@x = x
@y = y
@@n +=1
end
def Vector.report
@@n
end
NULL = Vector.new(0,0)
end
a = Vector.new(1,2)
b = Vector.new(2,4)
c = Vector.sum(a,b,Vector::NULL)
msgbox "("+c.x.to_s+","+c.y.to_s+")"
class Vector
attr_reader :X,:y
@@n = 0
def self.sum(*vecs)
x = y = 0
vecs.each{|v|x+=v.x;y+=v.y}
Vector.new(x,y)
end
def initialize(x,y)
@x = x
@y = y
@@n +=1
end
def Vector.report
@@n
end
NULL = Vector.new(0,0)
end
a = Vector.new(1,2)
b = Vector.new(2,4)
c = Vector.sum(a,b,Vector::NULL)
msgbox "("+c.x.to_s+","+c.y.to_s+")"