CIS 265 – Homework 4 – Quick Data Retrieval

The table below holds abbreviated statistics for the Cleveland Indians as of April 4th, 2013. The goal of the assignment is to (a) create a convenient data structure to keep the stats table in memory, and (b) provide a supporting structure to quickly retrieve all the figures associated to a player. The player’s last nameis used as a key.

TESTING

  1. After loading theroster data in memory, traverse the list printing each row.
  2. To test the ‘quick retrieval’ portion of the homework, perform a lookup on “Cabrera, A” and “Choo, S”. Show their statistics.
  3. Observe that several players are (perhaps) batting at the same level (in the sample two players are batting 385, three other players are hitting 200, and so on). List all the different batting scores recorded so far.

For your convenience the data is included as a .csv(comma separated) text file. The first row holds the column names. The first five rows of the file are:

RK, Player, FName, Team, Pos, G, AB, R, H, 2B, 3B, HR, RBI, BB, SO, SB, CS, AVG, OBP, SLG, OPS

1, Myles, B, CLE, LF,2,3,1,3,2,0,0,4,0,0,0,0,1,0.75,1.667,2.417

2, Paulino, D, CLE, SS,1,3,2,2,0,0,0,0,0,0,0,0,0.667,0.667,0.667,1.333

3, Henry, J, CLE, RF,3,5,0,3,0,0,0,1,0,0,2,0,0.6,0.6,0.6,1.2

4, Abraham, A, CLE, 1B,3,6,2,3,0,1,0,1,0,2,0,0,0.5,0.5,0.833,1.333

The output of your lookup operation may look like the following examples (try other players, try also invalid names):

Enter player’s name [type ### to END]
Cabrera

RK=28 Player= Cabrera A
Pos= SS G=14 AB=33 R=6

H=9 2B=3 3B=1 HR=1
RBI=7 BB=5 SO=5
SB=2CS=1

AVG=0.273

OBP=0.385
SLG=0.515
OPS=0.9

At the end of the program, print distinctbatting AVG values

Different Batting Averages
[161, 167, 170, 200, 205, 211, 217, 220, 227, 250, 268, 269, 271, 273, 286, 290, 300, 303, 313, 314, 327, 385, 455, 1000]

Webpage visited on 4/3/2013 Link:

RK=rank, G=games-played, AB=turns-at-bat, R=runs-scored, H=hits, 2B=doubles, 3B=triples, HR=home-runs, RBI=runs-batted-in, BB=base-on-balls, SO=strike-out, SB=stolen-bases, CS=caught-stealing, AVG=batting-average, OBP=On Base Pct, SLG= Slugging Pct, OPS= On-base Plus Slugging