Tool69
12/9/2005 11:02:00 PM
Thanks for all your answers, in fact, my class was already written with
the last mentioned code method.
class Point
attr_accessor :abs, :ord, :name, :cart
def initialize(abs,ord,name="")
@abs = abs
@ord = ord
@name = name
@cart = true
end
def to_s
"#@name : (#{@abs}, #{@ord})"
end
def ==(unPoint)
unPoint.abs = abs and unPoint.ord = ord
end
def Point.new_polaire(rho, theta, name)
@cart = false
@name = name
unPoint = new(rho*cos(theta),rho*sin(theta),@name)
return unPoint
end
end
....but I dislike the calling syntax. I thought it was possible to write
several constructors calls like in Java, ie :
void Move(Vector2D vector) {
center.x += vector.x;
center.y += vector.y;
}
void Move(double x,double y) {
center.x += x;
center.y += y;
}
So, my idea was bad : Ruby is not Java !