# Step 1: Define a class named Person
class Person
# Step 2: Define a constructor to initialize instance variables
def initialize(name, age)
@name = name
@age = age
end
# Step 3: Define a method to get the person's name
def get_name
@name
end
# Step 4: Define a method to get the person's age
def get_age
@age
end
# Step 5: Define a method to set the person's name
def set_name(name)
@name = name
end
# Step 6: Define a method to set the person's age
def set_age(age)
@age = age
end
end
# Step 7: Create an instance of the Person class
person = Person.new("John Doe", 30)
# Step 8: Use the get_name and get_age methods to retrieve information
puts "Person's Name: #{person.get_name}"
puts "Person's Age: #{person.get_age}"
# Step 9: Use the set_name and set_age methods to modify information
person.set_name("Jane Doe")
person.set_age(25)
# Step 10: Use the get_name and get_age methods again to confirm changes
puts "Updated Person's Name: #{person.get_name}"
puts "Updated Person's Age: #{person.get_age}"