# list0204.rb # アクセサ その1 class Point def initialize( x, y ) @x = x @y = y end def show print "(",@x,",",@y,")\n" end def get_x return @x end def set_x( x ) @x = x end end p1 = Point.new(1,2) puts p1.get_x p1.set_x(5) p1.show