Created
February 7, 2012 00:38
-
-
Save Greenie0506/1756205 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
People = [ | |
"John", | |
"Joe", | |
"Sue", | |
"Bob", | |
"Nick", | |
"Adam", | |
"Kevin"] | |
Games = [ | |
["Nick", "Adam"], | |
["Kevin", "Bob"], | |
["Sue", "Bob"], | |
["Joe", "Nick"], | |
["Kevin", "John"] | |
] | |
list_of_players = [] | |
class Player | |
def initialize(attributes) | |
@name = attributes[:name] | |
end | |
def name | |
@name | |
end | |
end | |
People.each do |person| | |
p = Player.new(:name => person) | |
list_of_players.push(p) | |
end | |
# puts list_of_players.inspect | |
list_of_matches = [] | |
class Match | |
def initialize(player_1, player_2) | |
@player_1 = player_1 | |
@player_2 = player_2 | |
end | |
def match_up | |
"#{@player_1.name} vs. #{@player_2.name}" | |
end | |
end | |
Games.each do |match| | |
m = Match.new(match[0], match[1]) | |
# puts match[0].inspect | |
list_of_matches.push(m) | |
end | |
# puts list_of_matches.map{|match| match.match_up } | |
found = list_of_players.find do |person| | |
person.name == "Nick" | |
end | |
puts found.inspect | |
puts list_of_matches.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment