Skip to content

Instantly share code, notes, and snippets.

@chadwickdonald
Created June 19, 2012 02:46
Show Gist options
  • Save chadwickdonald/2952022 to your computer and use it in GitHub Desktop.
Save chadwickdonald/2952022 to your computer and use it in GitHub Desktop.
baseball team
class BaseballTeam
def initialize()
@line_up = { 1 => { 'Aviles' => 'SS' },
2 => { 'Pedroia' => '2B' },
3 => { 'Youkilis' => '1B' },
4 => { 'Ortiz' => 'DH' },
5 => { 'Middlebrooks' => '3B' },
6 => { 'Gonzalez' => 'OF' },
7 => { 'Saltalamacchia' => 'C' },
8 => { 'McDonald' => 'OF' },
9 => { 'Byrd' => 'OF' },
0 => { 'Lester' => 'P' }
}
end
def get_lineup()
@line_up
end
def batting_order
order = []
@line_up.each do |key,player|
if player.values != ["P"]
order << player.keys.join("")
#puts "#{player.keys.join("")} is a pitcher!"
end
end
order
end
def substitution(number, player)
if @line_up[number].values == player.values
@line_up[number] = player
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment