class Point def initialize( x, y ) @x = x @y = y end #Create the default accessors for the x and y instance vars. attr_reader :x, :y attr_writer :x, :y def distance_from_origin return distance_from_point( Point.new(0,0) ) end def distance_from_point( p ) return Math.sqrt( (@x-p.x)*(@x-p.x) + (@y-p.y)*(@y-p.y) ) end end a = Point.new(3,4) b = Point.new(11,10) puts a.distance_from_origin puts a.distance_from_point(b)