Skip to content

Instantly share code, notes, and snippets.

@samtalks
Created September 27, 2013 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samtalks/6722934 to your computer and use it in GitHub Desktop.
Save samtalks/6722934 to your computer and use it in GitHub Desktop.
HW on 9/26. Speakers and Room assignments
# You're hosting a conference and need to print badges for the speakers. Each badge should say: "Hello, my name is _____."
# Write a method that will create and return this message, given a person's name.
def badge(name)
puts "Hello, my name is #{name}."
end
# Now the list of speakers is finalized, and you can send the list of badges to the printer. Remember that you'll need to give this list to the printer, so it should be accessible outside of the method.
speaker_list = %w(John Mike Liz Harry Betty)
# Modify your method so it can take a list of names as an argument and return a list of badge messages.
def badges(names)
names.each do |name|
puts "Hello, my name is #{name}."
end
end
# Your conference speakers are: Edsger, Ada, Charles, Alan, Grace, Linus and Matz. How you scored these luminaries is beyond me, but way to go!
speaker_list = %w(Edsger Ada Charles Alan Grace Linus Matz)
# You just realized that you also need to give each speaker a room assignment. You have rooms 1-7. You'll need to print this for the speakers, so make sure to return a list of room assignments in the form of: "Hello, _____! You'll be assigned to room _____!"
def badges(names)
i = 1
names.each do |name|
puts "Hello, #{name}! You'll be assigned to room #{i}!"
i += 1
end
end
# Write a method that assigns each speaker to a room, and make sure that each room only has one speaker. Return a list of room assignments
def schedule(names)
i = 1
names.each do |name|
puts "#{name} is assigned to #{i}"
i += 1
end
end
# Now you have to tell the printer what to print. Create a method that will output the results of the badge method and schedule method to the screen so the printer can do his thing.
def print(speaker_list)
badges(speaker_list)
schedule(speaker_list)
end
# Write a method to run the rest of your program and print the results to the screen. No other method should print to the screen.
# Didn't quite grasp what I'm supposed to do here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment