zcs-cs / Baseball-Reporter

The 2014-2015 AP Computer Science A class's final project that analyzes baseball statistics and compiles an automated news report.
GNU General Public License v2.0
0 stars 0 forks source link

Saves and Relief Pitchers #7

Closed avandesa closed 9 years ago

avandesa commented 9 years ago

Array for each team where each index contains the pitcher for that inning. Array for each team where each index contains the current score at the end of that inning.

Hunter-Bobeck commented 9 years ago

We already have your second component, that's easy.

For the first component, what if the team isn't pitching for the inning? Perhaps this should just be a single array (where index matches 'inning + 1'). And then does each inning have at most 1 pitcher? If not, we may need to invert it, have each player that is a pitcher have an integer array for each inning pitched. You would need to determine what you want from that.

avandesa commented 9 years ago

I like the idea of having an array for each pitcher, but how would that be organized (i.e. how would you identify the pitcher's number/name). Is there a class for each player containing their position, name, etc?

Hunter-Bobeck commented 9 years ago

Here's my explanation: https://github.com/zcs-cs/Baseball-Reporter/issues/10 So since you're on board, to be clear what I'll do... You are going to receive an int[][] of players' innings pitched. Go one level deep to acquire a player, so that index represents the player. Go another index deep to acquire an int[] of innings pitched, so if this int[] contains 1, 2, and 7 then that player pitched for innings 1, 2, and 7. This is a parallel structure.

ash402 commented 9 years ago

The best way as it seems to be is a 2D array, two rows deep. The first element being the inning, and the second being the name of the pitcher. If there are multiple pitchers in one inning, then the array can simply contain the inning number in as many columns as needed, and if there is no pitcher in a particular inning, then that inning number is simply omitted.

i.e., in this game...

index 0 1 2 3 4 5 6 7 8
inning 1 2 2 3 4 6 6 7 8
pitcher Harold Harold Kumar Sherman Sherman Sherman Quincy Quincy Norbit
Hunter-Bobeck commented 9 years ago

Instead of duplicating data, we're using a parallel structure. You'll need to call the players' names method to match player indeces with names (that returns a String[]). Also call the players' pitched innings method (that returns an int[][]) to match indeces (and indirectly names) with an int[] of innings pitched, such as {1, 2, 7}.