Description:
You will write a program which will model a baseball card collection. You'll
need this Sorts.java class (do not change it, use it
as is). You'll also find this input file handy: program5in.txt.
Sample output from the program (run with the input in program5in.txt) can be
found in program5out.txt.
Use this class diagram to help you
write your project: UMLprogram5.doc
Here is what the driver
program will do:
- ask the user how many baseball
cards will be read in
- read in and add that many baseball
cards to the collection. for each card, read player, team, year, condition,
price
- print out the entire collection
(use BBcardCollection's toString)
- ask the user if they'd like to
find a certain card
- if they say yes, get player, team,
and year from them
- search the entire collection for
all cards of that player, team, and year, and output them all, printing an
appropriate message if none were found
- ask the user if they'd like to
find a certain card again, continue to find cards as long as the user says
yes
- when the user says no, sort the
entire collection by price
- output the entire collection again
(use BBcardCollection's toString). This time, it should be sorted by price.
Here is a description of the methods
in the BBcardCollection class:
- Constructor - instantiates
a BBcardCollection by initializing instance data count and totalCost, and
instantiating the array of BaseballCards - its parameter is the size of the
array
- addCard - adds a card to
the array - instantiates a BaseballCard
- findMatches - gets, as
parameters, player, team, and year. Finds and prints all the BaseballCards
in the array with that player, team, and year.
- sortByPrice - this method
calls the insertionSort method in the Sorts class and passes it the array
of BaseballCards
- toString - prints out a
nicely formatted report showing all BaseballCards in the collection. Report
also shows the total number of cards, the total value of all the cards, and
the average value of a baseball card. calls the toString method for BaseballCard
Here is a description of the methods
in the BaseballCard class:
- Constructor - sets up a
Baseballcard
- equals - tests to see if
this baseball card is equal to the parameter baseball card. Two baseball cards
are the same if they have the same player, team, and year.
- compareTo - compares the
price of this baseball card to the price of the parameter baseball card.
- toString - prints out a
nicely formatted string of one baseball card
This is a non-trivial project with
many parts. It will take some time. You will need to study the UML diagram carefully
and understand and incorporate many concepts which we have been learning this
semester. You may use BaseballCard.java which was used in labquiz4, take 2.
You'll need to add a method to it, but everything in it can be used.
TURNING IN YOUR PROGRAM: You will
turn in three files: program5.java, BaseballCard.java, BBcardCollection.java.
PLEASE name the files as suggested: it expedites the grading process. I will
run your program with a different input file. Do not change the format of the
input file.