Program simulate a metropolitan subway train, C/C++ Programming

You're going to simulate a metropolitan subway train.  The train system will start out at Station #1, or Home  Station, and will service multiple stations along its route.

2114_Program Simulate A Metropolitan Subway Train.png



We have developed (or will develop) many of the basics for the class SubwayTrain in the classroom.  (For online students, I will post this class definition at an appropriate time.)  The train will run around a closed loop of rail, serving a number of stations that you will specify when you declare (instantiate) the object. It will be electric, so we don't ever have to worry about refueling it.  And it will always run in the same direction.

The train will carry a certain number of passengers from station to station, dropping off and picking up randomly-generated numbers of passengers at each station.  Generating those numbers will be part of your class-more on that later.

Once I post the class handout, you can start by building on that.  Or feel free to develop your own.  But you need to check the handout for the minimum specification. I will expect you to use all the instance variables and methods in the handout, at least as far as their purpose. If you rename them, that's fine, but the handout will contain the minimum instance variables and methods that must be implemented.   [One possible exception:  see later.]  The constructor needs to accept at least two values:  the number of stations on the complete route; and the maximum capacity of the train. The reason is so that you can simulate different sizes of systems and different sizes of trains.

When the simulation begins, generate a random number of passengers to board at Home Station (Station #1).  Then, run the train all around its system, serving every stop along the way, and finish back at Home Station. When departing each station, you must announce, at a minimum, the station you are leaving, the destination station, and the number of passengers on board.  When the train "arrives" at any station, it needs to announce how many passengers are departing and how many are boarding.  Both of these numbers will be randomly-generated, but the number of passengers you allow to board, for example, cannot end up exceeding the maximum capacity of the train.

Note on the random numbers.  It will not be acceptable if you restrict the size of your random numbers to values so low that the conductor never has to worry about the number wanting to board.  For example, if you have a capacity of 200, and you restrict your loading passenger number to 10, say, then certainly you will never have to worry about overloading!  That is not acceptable, since you then won't need any checks on any of these values in your loading method. Your class logic must ensure that the train is never overloaded, or that more passengers try to leave the train than are on board. Once in a while, your program should announce that too many people are trying to board, and only the allowable number will really be let on.  Just like real life, the rest will be left at the station (fuming!).

For this program, I want you to "build" a subway train that has a maximum capacity of 200 passengers and that has a total station count of 30 stations.  (Remember that Home Station is Station #1.)

For each stop you need to generate a random number between Ø and the number of pax already onboard, and that number of people will depart the train at this stop.  Then, generate another random number of pax to get on board the train. This random number of passengers waiting to board must be between 0 - 300.

For now, we won't worry about details such as how the customers will pay.  We'll save that problem for another day.

One final note:  since we have not discussed in depth how class methods can call each other, I am not making that a mandatory part of this program.  It will be worth extra credit.  If you want to use main to run the train around the route, that is OK.  In other words, if you call all of the appropriate methods from main, then you will probably not have a single runTheRoute method that is referenced in the handout for the class.  Just be sure that the class can take care of itself if you "run the train" from main.  For example, checking for how many passengers that can board must surely be done inside an appropriate method.

The name of your solution should be this:  Program4 Solution name, where name is your last name.

Call only two public methods from main: the constructor and a method to start the train rolling. The runTheRoute method in the handout was intended for just that purpose: to run the train completely around the system one time. This means that the train object will be a completely self-contained simulation.

Posted Date: 2/20/2013 4:52:04 AM | Location : United States

Related Discussions:- Program simulate a metropolitan subway train, Assignment Help, Ask Question on Program simulate a metropolitan subway train, Get Answer, Expert's Help, Program simulate a metropolitan subway train Discussions

Write discussion on Program simulate a metropolitan subway train
Your posts are moderated
Related Questions
how to make program c++

Write a program that displays the following temperature conversion chart on the screen as follows below. Hint: c = 5.0/9.0 * (f - 2) C = degrees in Celsius F = degree in F

Define a structure in C++: Write a program a structure in c++ program. void main() {                 struct player                 {                 char name[2

C program to demonstrate Pointer to variable: void p2a(int *); void main() {                 int x=10, *a,**b;                 int arr[5];                 //poin

Write a program called Series that will print/display a series of numbers starting with 1 and ending with the last number that is less than 30. The series should include only odd n

Define the Data Type Modifiers in C language? There are three data types(int, float & double) above have the following modifiers. 1. short 2. long 3. signed 4. unsigned

Write a program that does the following: Calculates the Velocity and Momentum of an object. The formula for the velocity is V=d/t and the formula Momentum is m=mass*velocity. Your

Make QtAV Videoplayer simple integrateable for Qt Applications Project Description: I'm preparing an application for Windows and Mac using QtCreator. I want a videoplayer

what will be the c program for ideal gas equation.