Skip to content

Instantly share code, notes, and snippets.

@oleander
Created June 26, 2011 18:24
Show Gist options
  • Select an option

  • Save oleander/1047825 to your computer and use it in GitHub Desktop.

Select an option

Save oleander/1047825 to your computer and use it in GitHub Desktop.
class Guest
attr_accessor :first_name, :last_name, :age
end
class Hotel
attr_reader :guests
def initialize
@guests = []
end
def add_guest(guest)
@guests.push(guest)
end
end
guest = Guest.new
hotel = Hotel.new
puts "What's your name?"
guest.first_name = gets
puts "What's your last name"
guest.last_name = gets
puts "What's your age?"
guest.age = gets
hotel.add_guest(guest)
puts hotel.guests.first.first_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment