Created
October 5, 2012 23:17
-
-
Save superacidjax/3843013 to your computer and use it in GitHub Desktop.
WDI Lab 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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