Skip to content

Instantly share code, notes, and snippets.

@stevenabrooks
Created June 11, 2013 12:43
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 stevenabrooks/5756509 to your computer and use it in GitHub Desktop.
Save stevenabrooks/5756509 to your computer and use it in GitHub Desktop.
actually really impressed how i was able to do this pretty well
$basketball_game =
{
:team_1 =>
{
:team_name => "Nets",
:color => ["black", "grey"],
:player_1 =>
{
:name => "Brooke Lopez",
:jersey => 11,
:shoe_size => 20,
:stats =>
{
:points => 18,
:rebounds => 18,
:assists => 3,
:steals => 0,
:blocks => 6,
:dunks => 4
}
}
:player_2 =>
{
:name => "Kris Humphries",
:jersey => 43,
:shoe_size => 16,
:stats =>
{
:points => 10,
:rebounds => 12,
:assists => 3,
:steals => 0,
:blocks => 5,
:dunks => 4
}
}
:player_3 =>
{
:name => "Gerald Wallace",
:jersey => 45,
:shoe_size => 16,
:stats =>
{
:points => 16,
:rebounds => 10,
:assists => 7,
:steals => 0,
:blocks => 10,
:dunks => 1
}
}
:player_4 =>
{
:name => "Joe Johnson",
:jersey => 7,
:shoe => 15,
:stats =>
{
:points => 21,
:rebounds => 8,
:assists => 7,
:steals => 1,
:blocks => 1,
:dunks => 1
},
},
:player_5 =>
{
:name => "Deron Williams",
:jersey => 8,
:shoe => 14,
:stats =>
{
:points => 17,
:rebounds => 10,
:assists => 20,
:steals => 10,
:blocks => 10,
:dunks => 0
},
},
}
:team_2 =>
{
:team_name => "Lakers",
:color => ["purple", "yellow"],
:player_1 =>
{
:name => "Dwight Howard",
:jersey => 12,
:shoe_size => 22,
:stats =>
{
:points => 18,
:rebounds => 18,
:assists => 0,
:steals => 0,
:blocks => 0,
:dunks => 9
}
}
:player_2 =>
{
:name => "Paul Gasol",
:jersey => 16,
:shoe_size => 18,
:stats =>
{
:points => 10,
:rebounds => 12,
:assists => 0,
:steals => 0,
:blocks => 5,
:dunks => 4
}
}
:player_3 =>
{
:name => "Metta World Peace",
:jersey => 15,
:shoe_size => 12,
:stats =>
{
:points => 6,
:rebounds => 10,
:assists => 7,
:steals => 9,
:blocks => 8,
:dunks => 1
}
}
:player_4 =>
{
:name => "Kobe Bryant",
:jersey => 24,
:shoe => 30,
:stats =>
{
:points => 35,
:rebounds => 3,
:assists => 0,
:steals => 1,
:blocks => 1,
:dunks => 8
},
},
:player_5 =>
{
:name => "Steve Nash",
:jersey => 10,
:shoe => 6,
:stats =>
{
:points => 5,
:rebounds => 5,
:assists => 25,
:steals => 1,
:blocks => 0,
:dunks => 0
},
},
}
}
# Using the power of Ruby, and the Hashes you created above, answer the following questions:
# Return the number of points scored for any player:
#
puts "#{$basketball_game[:team_1][:player_1][:stats][:points]}"
# Return the shoe size for any player:
#
puts "#{$basketball_game[:team_1][:player_1][:shoe]}"
# Return both colors for any team:
#
puts "#{$basketball_game[:team_1][:colors]}"
# Return both teams names:
#
puts "#{$basketball_game[:team_1][:team_name]} + #{$basketball_game[:team_2][:team_name]}"
# Return all the player numbers for a team:
#
# Return all the stats for a player:
#
puts "#{$basketball_game[:team_1][:player_1][:stats]}"
# Return the rebounds for the player with the largest shoe size
#
# Bonus Questions: define methods to return the answer to the following questions:
# Which player has the most points?
#
# Which team has the most points?
#
# Which player has the longest name?
#
# Super Bonus:
# Write a method that returns true if the player with the longest name had the most steals:
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment