Created
September 27, 2013 02:59
-
-
Save TrevMcKendrick/6723606 to your computer and use it in GitHub Desktop.
This file contains 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
# 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) | |
"Hello my name is #{name}" | |
end | |
#badge("Trevor") | |
# Now the list of speakers is finalized, and you can send the list of badges | |
# to the printer. *Remember that 2you'll need to give this list to the printer, | |
# so it should be accessible outside of the method.* | |
# **Modify your method so it can take a list of names as an argument and | |
# **return a list of badge messages.** | |
def group_badges(names) | |
array = [] | |
name.each do |the_name| | |
array << "Hello my name is #{the_name}" | |
end | |
array | |
end | |
#group_badges(["Trevor","Breanna"]) | |
# Your conference speakers are: `Edsger, Ada, Charles, Alan, Grace, Linus and | |
# Matz.` How you scored these luminaries is beyond me, but way to go! | |
# 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 _____!" | |
#speakers = [Edger,Ada,Charles,Alan,Grace,Linus,Matz] | |
def group_badges(names) | |
assignments = [] | |
names.each_with_index do |the_name, index| | |
assignments << "Hello #{the_name}! You'll be assigned to room #{index + 1}" | |
end | |
assignments | |
end | |
#group_badges(["Edger","Ada","Charles","Alan","Grace","Linus","Matz"]) | |
# **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** | |
# 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. | |
# **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.** | |
def print_names(names) | |
puts group_badges(names) | |
end | |
print_names(["Edger","Ada","Charles","Alan","Grace","Linus","Matz"]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment