Assignment 2: Baseball Fever Due Thursday July 1 at 9:00pm

For some people, summer and baseball and practically inseparable.  Baseball and statistics are practically inseparable, too.  Let's enjoy all three by making a program to help organize and locate some baseball facts. 

PART I:


All files (java, test data, etc.)    Java documentation  posted 6/28: baseball1.jar file (baseball, MDUtils, textfile packages: .class files only; see Message Board)

Let's review our object-oriented approach to programming and add a little bit of inheritance to it this time.  We'll need a class Team to model a baseball team; League to model collection of Teams; a class Player for players; and two more classes, Pitcher and Hitter for specific types of players.  Think about what the relationships between these classes should be.  Unlike Major League Baseball, we will put all our teams in one League this.

Although we will have plenty of data on which statistics could be calculated, the emphasis of the project is on organization, not number-crunching: organizing the data among classes, getting the data into the right classes and being able to locate it; and organizing your classes and packages so that things compile and execute properly.

As data, we will use files with real information, derived from the Major League Baseball Statistics site (you will need to visit that site to know what the fields are).  The information has already been extracted for you in the form of text files.  Using a class we supply called DelimitedTextFile, you can read each line of a file into an ArrayList of Strings, one string for each field.  Then you can build objects of the right types from that.

Here is an outline of the required processing:
Notes

Hand in the files electronically electronically by the due date at the top of this page

In addition, write a short technical description (at most one page, but a paragraph will probably do) of your program and how it works. Turn this in (hardcopy) at the next lecture after the due date above.  As usual on any written part, unless you handwriting is exceptionally clear, please type it!


Note on the data files:
We have supplied a class called DelimitedTextFile to make it easy to read the files.   To use it, construct a DelimitedTextFile passing the name of the file as a parameter.  Then the only method you will probably need is called readLineAsFieldList, which reads a line, parses it into fields, and gives you all the fields as a List.  For example, the following should actually compile and run:

DelimitedTextFile myfile = new DelimitedTextFile(aFileName);
List fields = myfile.readLineAsFieldList();
while (fields != null) {
    //do something with the fields -- create an object, save data, whatever
    fields = myfile.readLineAsFieldList();
}
To find out what the fields are, visit the baseball site mentioned earlier and look at the original data.  The files will have many more fields than you actually need for this assignment!  There's no requirement to use or save all of that data in the objects you create.  You may ignore the fields that are not going to be used.  On the player files, a hitter's batting average is the number in the last column (marked AVG on the web site).

One thing missing from the files is a way to match a team name (like "Seattle Mariners", used on the team file), with the team code (like SEA, used in the player files).  Somehow you should build this into your program so you can put players on the right team (if that matters).  Do not modify the data file!  If you do, your program won't work when the TA runs it with the original file.

Get started early and good luck!