Homework 6, Train Cars are Stacking Up

For this program you will implement a simulation of a simple railroad switching yard.

Goals

Formal Description

You are working for a railroad company with a number of small switching yards. They have hired you to implement a simulation of the flow of traffic in these yards.

A yard is configured as follows:

You should assume each spur can hold no more that 100 cars. If any spur ever exceeds this limit, the program should report the error message
ERROR spur capacity exceeded!
If there is an attempt to place more than the maximum number of cars of a spur, discard the car that would cause the spur to overflow.

In a similar manner, if an attempt is made to remove a car from an empty spur the program should report the error message

ERROR spur is empty, cannot remove a car!
If this error occurs, any function responsible for returning a car should return ERROR_CAR which is defined below.

Commands

Your simulation should respond to the following commands:

A trainlist consists of a comma separated list of train cars, listed from front to back. A train car consists of a car id, which is a unique string, a colon and a destination, which is a string. See below for a full list of destinations.

Assume all spurs are empty. The command arrive Local C:Oakland,B:Cleveland,A:Denver would produce the following

              
                           LOCAL    YARD
			     C
			     B
		WEST         A			EAST

General Operation

Your program should prompt the user for a file with the prompt
Enter the file name =>
There should be a space after the > in this prompt. Note, this prompt does not include the newline character. However, after you have read the file name, please print a newline character.

The first word in the file will be the station name. This will be a valid destination.

The program should then attempt to execute the commands in the file. You may assume all commands are valid.

The following is an example of a valid input file

Edinboro
arrive local A:Albion,B:Cambridge Springs
ArrIve wEsT  C:Bradford,D:Edinboro,E:Erie
SORT wesT
Move west East
Depart East

Output

As commands are executed

Implementation

Please implement your program as follows:

Required Test File

Discussion

Required Files

A tar file containing the all source code required to build both programs in this project. This file should also contain a Makefile capable of building the programs required for this project. It should not contain executable or object files.

Submission

Send the tar file to your instructor as an attachment to an email message by the due date.