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
write the program to accept date and to say valid or invalid

Write a C program to input your full forename and full surname. e.g James McCarren and display in one string your complete initial and surname i.e J McCarren . Your initial should

I need whatsapp software in my website Project Description: i need whatsapp software in my website same this whatsapp if anyone can make to me this in my website Skills

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

C Program for FUNCTION OF FIND THE FACTORIAL float factorial(float); void main() {           float i=0,c=0;           clrscr();           printf("ENTER THE DIGI

Program is to display the contents of file on a screen: Write a program to display the contents of file on a screen void main()   {  clrscr();  ifstream fin("ascii

#questionhow can i add new customer and alot him a new unique id ..

Problem : Change to palindrome A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your ta

Array of Objects: The objects can be declared just like a structure or even a primary data type.  Array of objects may be required to work with large set of data.   When the da

minimum of seven number