Vector: Difference between revisions

no edit summary
No edit summary
Line 1,023:
ReadChar
END Vector.</lang>
 
=={{header|Nanoquery}}==
{{trans|Java}}
<lang nanoquery>class Vector
declare x
declare y
 
def Vector(x, y)
this.x = float(x)
this.y = float(y)
end
 
def operator+(other)
return new(Vector, this.x + other.x, this.y + other.y)
end
 
def operator-(other)
return new(Vector, this.x - other.x, this.y - other.y)
end
 
def operator/(val)
return new(Vector, this.x / val, this.y / val)
end
 
def operator*(val)
return new(Vector, this.x * val, this.y * val)
end
 
def toString()
return format("[%s, %s]", this.x, this.y)
end
end
 
println new(Vector, 5, 7) + new(Vector, 2, 3)
println new(Vector, 5, 7) - new(Vector, 2, 3)
println new(Vector, 5, 7) * 11
println new(Vector, 5, 7) / 2</lang>
{{out}}
<pre>[7.0, 10.0]
[3.0, 4.0]
[55.0, 77.0]
[2.5, 3.5]</pre>
 
=={{header|Objeck}}==
Anonymous user