CPSC 220 Fall 2005
Program 2: More Games
Overview
In program 1 you wrote a program that took a list of lacrosse teams and
a file of results and recreated the schedule for each of the teams.
In this assignment you will expand that program so that the game information
can also be accessed efficiently by date.
Assignment
Enhance your code from program 1 as follows:
- Continue to read and store the teams from file teams.dat.
You will still need to be able to search efficiently for a team by team code.
- Continue to read in the game scores from file scores.dat. However,
when you read in a game, store it in a balanced tree that is
structured as follows:
- Each node of the tree should represent a single date.
- All of the games played on a given date should be stored at the
node for that date. You can decide what structure to use to store them.
In addition, continue to store each game in the schedule for each of the
teams playing. However, both of the schedules should refer to the
game object stored in the balanced tree -- there should not be multiple
objects representing the same game.
Input and Output
As in program 1, you will take your input from files teams.dat and
scores.dat. Your program will again be interactive;
you should provide a menu-driven interface so that in addition
to getting the schedule
for a given team, the user can do the following:
- Enter a date in format mm/dd and get a list of all games played on
that date. This list should be in alphabetical order by home team code,
which is the order used in the input file.
- Enter a date and team and get the results of that team's game(s)
on that date, if they played.
- Enter a date and two teams that play each other on that date
and modify the results of the game. These modifications should be stored
in the program but should not be written back to the file. The program
should provide the information currently stored on the game and then
ask the user to provide new information any field(s) except date and team codes.
So either team's score, overtimes, neutral, etc should all be
modifiable.
Guidelines
You will need to write a balanced search tree
class to store your games by date.
You may use an AVL tree or a red-black tree, as you prefer. Note that
both of these are special kinds of binary search trees, so they should
extend a BST class.
And you're in luck; here is code for a generic BST class for you to build
on. Note that it implements the BST interface
and relies on the standard BTNode class.
You may need to enhance to BTNode class to hold additional information
at each node.
As on program 1, you may consult with each other on this program but you may
not copy significant amounts of code from each other or from anywhere else.
In particular, you are expected to write your own balanced tree class.
Turn in hardcopy and e-mail me a tar file.