Created
June 19, 2012 02:46
-
-
Save chadwickdonald/2952022 to your computer and use it in GitHub Desktop.
baseball team
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
| 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