class Point
attr_reader :x, :y
def initialize(x, y)
@x = x
@y = y
end
end
class Point
def self.get_distance(p1, p2)
d1 = (p1.x - p2.x).pow(2)
d2 = (p1.y - p2.y).pow(2)
return Math.sqrt(d1 + d2)
end
end
p1 = Point.new(1, 2)
p2 = Point.new(2, 3)
distance = Point.get_distance(p1, p2)
# distance is 1.4142
puts "distance is #{distance}"