CMPU-235: Software Development Methodology

Homework #3

Due: Wednesday, Oct. 4 and Friday Oct. 6

Note updates on 10/1 in blue

Congratulations! So impressed was I with your second assignments that took it upon myself to contact the NBA and respond to a request for proposals to develop a system for keeping track of NBA players - with all the trading that goes on these days, they're beginning to lose track. No knowledge of basketball is required.

Here's what you have to do:

  1. If you haven't already, define a full class for player. Players should have a name, number, total number of points scored, total number of assists, and total number of games played. Define an interface to this class that includes at minimum methods for entering data and printing them out. See below for the i/o method requirements.
  2. Define a team class. A team has a name, a city, and players that play for it. Define an interface to this class that also provides for printing out the team and entering the data.
These interface files (player.h and team.h) are due on Wednesday, Oct. 4.

Implement both interfaces and write a main program that reads in a team and prints it out. Your implementations are due on Friday, Oct. 6.

Each class should provide a set of i/o methods for reading in from the keyboard, from a file, and printing to the screen or to a file. The interfaces should be roughly:

istream& operator>>(istream& i, player* a);   // read player from keyboard
ifstream& operator>>(ifstream& i, player* a); // read player from a file
ostream& operator<<(ostream& o, player* a);   // output player to screen
ofstream& operator<<(ofstream& o, player* a); // output player to file
You should plan that your file i/o functions will be designed and implemented to work together, that is the file output method will create a file that can be read by the file input method.

Your implementation must use only the STL classes for implementing any containers you use. You may not use C character arrays for strings, or C arrays to store information (note: except for argv). You may use any STL container you wish.

In addition to style, documentation, whether it compiles and implements all the functionality described here, 10 pts (of 100) of the grade will be based on the size of your main program (that is, the amount of code that is not part of your class implementations, including non-member methods your main may call). The shorter, the better.

Work incrementally and methodically. Do not write your whole program at once. Write small pieces and get them to work before adding the next peice. Only the interface should be designed all at once.

Additional information on your main() function:

Generally speaking, Unix programs do not use menus or much of a user interface, instead of relying on an read-process loop for entering commands, they usually provide a command-line interface which basically lets you specify the command you want the program to perform as part of the command line. In this assignment, your main will process two command line options, one for reading input from the keyboard and saving the results to a file, and one for reading input from a file and displaying the results on the screen.

Consider something like this:

main(int argc,char *argv[])
{
  if (argc != 3) {
    cerr << "Usage: myprog -[io] file" << endl;
    return(1);
  } else if (strcmp(argv[1],"-i") == 0) { 
    // read input from file, display to screen
  } else if (strcmp(argv[1],"-o") == 0) {
    // read input from kybd, save to file
  } else {
    cerr << "Invalid command line option.  Use -i or -o." << endl;
    return (2);
  }

  return(0);
}