Skip to content

Instantly share code, notes, and snippets.

@superacidjax
Created October 5, 2012 23:17
Show Gist options
  • Select an option

  • Save superacidjax/3843013 to your computer and use it in GitHub Desktop.

Select an option

Save superacidjax/3843013 to your computer and use it in GitHub Desktop.
WDI Lab 1
class Person
attr_accessor :name, :email, :age
def initialize(n, e, a=18)
@name = n
@email = e
@age = a
end
def to_s
"The person's name is #{@name} and email #{@email} and age #{@age}"
end
end
people = []
puts "Do you want to create a person? (y/n)"
response = gets.chomp
while response == 'y'
puts "Name?"
name = gets.chomp
puts "Email?"
email = gets.chomp
puts "Age?"
age = gets.chomp
person = Person.new(name, email, age)
people << person
puts "Do you want to create a person? (y/n)"
response = gets.chomp
end
people.each do |person|
puts person
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment