UMBC CS 201, Spring 99
UMBC CMSC 201 Spring '99 CSEE | 201 | 201 S'99 | lectures | news | help

CMSC 201
Programming Project Five

Major League Baseball

Out: Wednesday 4/28/99
Due Date: Thurdsay, 5/13/99 before midnight

The Objective

The purpose of this assignment is to give you more practice with file I/O, new string handling functions and once again the opportunity to design the entire project. This project also requires you to become familiar with the basic Linked-List operations of Insert, Find and Delete.

The Background

The concepts inherent in linked-list manipulation, especially handling structures with self-referencing pointers are fundamental to many Abstract Data Structures you will encounter in computer science. This project gives you your first chance to experience the joys, trials and tribulations of such data structures.

The Task

This project requires you to maintain information about imaginary major league baseball teams and players. Team and player information will be provided in a text file of commands. You will create teams, add players to teams, remove players from teams, trade players between teams and print team rosters.

Command File Specification

The command file is /afs/umbc.edu/users/s/b/sbogar1/pub/proj5.cmds DO NOT modify this file in any way. Your code will be very sensitive to the contents of this file. Adding a single space or newline will cause your program to fail or even core dump!

Command File Details

  1. Each command in the file and its parameters are on a separate line, terminated by the newline character
  2. All command parameters are separated with a comma
  3. The following command formats are found in the file
Where
  1. The TEAM command defines a new team. There will be no more than 4 teams defined.
  2. The ROSTER command prints the team information including data on all players on the team
  3. The TRADE command causes player1 and player2 to switch teams
  4. The REMOVE command removes the player from the team
  5. The ADD command adds a player to a team.
  6. player id is the player's Major League Baseball ID and is a unique number.
  7. position number is the standard number used for official scoring in Major League Baseball as defined below:
    1. Pitcher
    2. Catcher
    3. First base
    4. Second Base
    5. Third base
    6. Shortstop
    7. Left Field
    8. Center Field
    9. Right Field
  8. salary is in dollars
  9. batting average is between 0.000 and 1.000, with 3 decimal places

Program Requirements

  1. Your progam must support all of the commands described above.
  2. Each command must output an appropriate message when executed
  3. You must use the following structure definitons typedef struct player { int MLBId; /* Major League BB ID (unique player id) */ char name [50]; /* first, last and moniker */ double battingAve; /* 3 decimal places */ long salary; /* dollars */ int position; /* see above */ } PLAYER; typedef struct node { PLAYER player; /* struct in a struct */ struct node *next; /* self referencing pointer */ } NODE; typedef struct team { char name [20]; /* team name */ char owner [25]; /* owner's name */ char manager [25]; /* manager's name */ NODE *players; /* list of players */ } TEAM;
  4. Your program must use command line arguments to input the name of the command file.
  5. Your project must use separate compilation. The main file must be named proj5.c. Other source files (.c) and header files (.h) may be named as you feel appropriate.
  6. Your program should contain an array of TEAM structures, each of which contains PLAYER information sorted by MLBId and stored in a linked-list of NODEs

Program Hints

Sample Run

retriever [123] a.out proj5.cmds CREATED TEAM : Lions ADDED PLAYER : Tom Triple (9988) to Lions ADDED PLAYER : Butch "The Truth" Nixon (7766) to Lions ADDED PLAYER : Zach "The Hack" Davis (3322) to Lions REMOVED PLAYER: Butch "The Truth" Nixon (7766) from Lions ADDED PLAYER : Fred Greene (5544) to Lions ADDED PLAYER : Dylan Thomas (1100) to Lions CREATED TEAM : Tigers CREATED TEAM : Bears ADDED PLAYER : Phil Jacobs (9876) to Bears ADDED PLAYER : Tommy Rogers (1122) to Tigers ADDED PLAYER : Alex Borders (1098) to Bears ADDED PLAYER : Hank Fish (2233) to Tigers ADDED PLAYER : Pete McMahon (4455) to Tigers ADDED PLAYER : Steve Hutchins (4433) to Lions ADDED PLAYER : Ronnie "The Tree" Maples (3344) to Tigers REMOVED PLAYER: Pete McMahon (4455) from Tigers ADDED PLAYER : Eddie Clayton (8899) to Tigers ADDED PLAYER : Walt Plum (8877) to Lions ADDED PLAYER : Bill Jefferson (5566) to Tigers ADDED PLAYER : V. Edward Murphy (7788) to Tigers ADDED PLAYER : Richard "Richie" Davenport (9900) to Tigers ADDED PLAYER : Bobby Miller (6677) to Tigers REMOVED PLAYER: Eddie Clayton (8899) from Tigers ADDED PLAYER : Kenny Taylor (5432) to Bears ADDED PLAYER : Isaac Fremont (7654) to Bears ADDED PLAYER : Lenny Johns (4321) to Bears ADDED PLAYER : Gary "Sour Grapes" Lemon (6655) to Lions ADDED PLAYER : Quenton "The Q" Henry (6543) to Bears ADDED PLAYER : Charlie "The Tuna" Fish (2211) to Lions ADDED PLAYER : Sam McMarkus (8765) to Bears ADDED PLAYER : Trevor Johnson III (3210) to Bears ADDED PLAYER : Larry McMichaels (2109) to Bears TRADED PLAYERS: Tigers player V. Edward Murphy (7788) traded for Bears player Kenny Taylor (5432) TRADED PLAYERS: Tigers player Tommy Rogers (1122) traded for Lions player Tom Triple (9988) TRADED PLAYERS: Lions player Charlie "The Tuna" Fish (2211) traded for Bears player Isaac Fremont (7654) TRADED PLAYERS: Tigers player Tom Triple (9988) traded for Bears player V. Edward Murphy (7788) TRADED PLAYERS: Tigers player Richard "Richie" Davenport (9900) traded for Lions player Steve Hutchins (4433) REMOVED PLAYER: Alex Borders (1098) from Bears REMOVED PLAYER: Phil Jacobs (9876) from Bears PRINT ROSTER : Lions -------------------- Lions Team Roster -------------------- Owner: Randy Rogers Manager: Lenny the Lip Players: MLBID Name Position Ave Salary ---- ------------------------- -------- ---- -------- 1100 Dylan Thomas ShortStop 0.266 1300000 1122 Tommy Rogers Pitcher 0.256 800000 3322 Zach "The Hack" Davis 2nd Base 0.304 1650000 5544 Fred Greene Center Field 0.289 890000 6655 Gary "Sour Grapes" Lemon Pitcher 0.130 900000 7654 Isaac Fremont ShortStop 0.321 1500000 8877 Walt Plum Left Field 0.297 2000000 9900 Richard "Richie" Davenport Right Field 0.288 890000 PRINT ROSTER : Tigers -------------------- Tigers Team Roster -------------------- Owner: Rusty Jones Manager: Bob Smith Players: MLBID Name Position Ave Salary ---- ------------------------- -------- ---- -------- 2233 Hank Fish Catcher 0.303 950000 3344 Ronnie "The Tree" Maples 1st Base 0.321 1200000 4433 Steve Hutchins Right Field 0.344 3600000 5432 Kenny Taylor Catcher 0.286 785000 5566 Bill Jefferson 3rd Base 0.315 1400000 6677 Bobby Miller ShortStop 0.325 3000000 7788 V. Edward Murphy Left Field 0.299 2400000 -------------------- Bears Team Roster -------------------- Owner: Mike Johnson Manager: Kenny the Kid PRINT ROSTER : Bears Players: MLBID Name Position Ave Salary ---- ------------------------- -------- ---- -------- 2109 Larry McMichaels Center Field 0.322 5500000 2211 Charlie "The Tuna" Fish 3rd Base 0.302 3100000 3210 Trevor Johnson III Right Field 0.350 4750000 4321 Lenny Johns 1st Base 0.234 650000 6543 Quenton "The Q" Henry 3rd Base 0.335 1250000 8765 Sam McMarkus Left Field 0.358 3600000 9988 Tom Triple Catcher 0.245 300000

Submitting the Program

To submit your program, type the following command at the Unix prompt

submit cs201 proj5 proj5.c

To verify that your project was submitted, you can execute the following command at the Unix prompt. It will show all files that you submitted in a format similar to the Unix 'ls' command.

submitls cs201 proj5


CSEE | 201 | 201 S'99 | lectures | news | help

Wednesday, 28-Apr-1999 11:45:26 EDT