KillerDesigner
10/6/2013 - 2:03 AM

person.rb


class Person

  def initialize(name="no name")
		@name = name
	end	

	# Set method it
	def name=(other_name)
		@name = other_name
	end

	# Get method
	def name
		@name
	end

	def say_hello
		puts "Hello, I am #{@name}"
	end 


end

person = Person.new()

# Setter method for name
person.name = "Smith"
person.say_hello

# Getter method for name
puts person.name