Background:
Lab 7 will focus on using inheritance in two places: extending an Athlete class to support a new player - a BasketBall player and extending a generic
linked list class (MyLinkedList) of Comparables to a linked list of Athletes.
What You'll Need
Download the lab7.zip file from the 15-111 course web site. Unzip
the file and you should see the following:
- Athlete.java - a class for storing common information about all athletes. You will need to implement the compareTo method for this class
- HockeyPlayer.java - a completely implemented subclass for a hockey player
- VballPlayer.java - a completely implemented subclass for a volleyball player
- MyLinkedList.java - a completely implemented linked list of Comparables
- AthleteLinkedList.java - a stubbed version of a subclass that extends MyLinkedList to allow for operations (mostly traversals) on lists of Athletes. You will need to implement all of the stubbed methods.
- Players.java - the class that implements the player database. You will need to implement its constructor and its toString method.
- smalldata.txt, an abbreviated data file to test your code
- athletes.txt, a larger file for more interesting results
Assignment
You are provided with a lot of code. You will need to
- create a new class to store a Basketball player patterned after the VballPlayer and HockeyPlayer classes. I would suggest doing this first.
- implement compareTo in the Athlete class to allow for two athletes to be compared by name
- implement all the methods in the AthleteLinkedList class. These are various traversals (including toString) needed by the Players class. The Node inner class and
head instance variable in the MyLinkedList class have been made protected to facilitate these implementations.
- implement the constructor for the Players class that reads and tokenizes the datafile and creates appropriate objects for each line in the file. As each object is created, it is to be inserted in alphabetical order (see compareTo in the Athlete class) into an ordered AthleteLinkedList. You will also need to implement the toString method for this class.
A discussion of the design and demo of the solution will take place in Thursday's lecture.
Handing in your Solution
Your solution should be in the form of a .zip file. When we grade your solution
we will unzip the folder and execute the project.
Use the Intro Programming
dropoff form to submit your zip file.