Created
September 16, 2013 15:47
-
-
Save elreimundo/6582453 to your computer and use it in GitHub Desktop.
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
TIGERS = {1 => 'Morgan, Kiera, John', 2 => 'Dave, Bruno, Max', | |
3 => 'David, Nick, Lionel', 4 => 'Elmer, Juke, Robert', | |
5 => 'Tom, Tyler, Gary', 6 => 'Sunny, Daniel, Nathan', | |
7 => 'Doug, Rao, Nishant'} | |
class Console | |
def initialize | |
@gophers = {} | |
puts "Welcome to GroupMatcher(tm)!" | |
puts "When you've finished all groups, type 'Match!'" | |
get_new_group | |
end | |
def get_new_group | |
puts "#{@gophers.empty? ? 'A' : 'Another'} group contains these three students:" | |
names = [] | |
3.times do | |
print "Student first name:" | |
name = gets.chomp | |
if name == 'Match!' | |
@gophers[@gophers.size] = names.join(', ') unless names.empty? | |
match_em_up! | |
end | |
names << name | |
end | |
@gophers[@gophers.size] = names.join(', ') | |
get_new_group | |
end | |
def match_em_up! | |
pairs = TIGERS.keys.shuffle.zip(@gophers.keys) | |
puts "Your pairs are:" | |
pairs.each {|pair| puts "#{TIGERS[pair[0]].ljust(30)} | #{@gophers[pair[1]]}"} | |
exit | |
end | |
end | |
console = Console.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment