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

Assignment Help:

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

SPECIFIC DIRECTIONS

EVERYTHING MUST BE DONE IN THE HEADER FILE, ONLY USE THE .CPP TO CALL THE FUNCTIONS!  ANY CODE IN THE .CPP FILE WILL RESULT IN A 0!

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.


Related Discussions:- Program simulate a metropolitan subway train

Program to implement a ftp client, Write a program in C to implement a FTP ...

Write a program in C to implement a FTP client that can interoperate with a default FTP server . The client should implement basic FTP commands GET PUT LIST DELE . GET -> to

Can any constructor throw an exception?, Can any constructor throw an excep...

Can any constructor throw an exception? How to handle error while the constructor fails?

I want application to generate premium, Project Description: We want to ...

Project Description: We want to generate premium numbers for one of our application. What we need is: A program that generate 2, 3, 4, 5, 6, 7, 8 digits premium numbers

#padovan string, #padovan string   program in java // aakash , sur...

#padovan string   program in java // aakash , suraj , prem sasi kumar kamaraj college program 1 : package test.padovanstring; public class PadovanString {

C program to find the even words in the string, C Program to FIND THE EVEN ...

C Program to FIND THE EVEN WORDS IN THE STRING #include conio.h> #include stdio.h> void main() {           char a[50],temp;           int i=0,k=0,l[25],c=0,r=0;

Stack and queues, Using Figure 10.2 as a model, illustrate the result of ea...

Using Figure 10.2 as a model, illustrate the result of each operation in the sequence ENQUEUE.Q; 4/, ENQUEUE.Q; 1/, ENQUEUE.Q; 3/, DEQUEUE.Q/, ENQUEUE.Q; 8/, and DEQUEUE.Q/ on an i

Explain the standard input/output iostream library, Question 1 Implemen...

Question 1 Implement a class stack which simulates the operations of the stack allowing LIFO operations. Also implement push and pop operations for the stack 2 Explain the c

Arrays and pointers, i have an array of structs, and am trying to make a po...

i have an array of structs, and am trying to make a pointer that can point to a certain struct within the array

Largest clique, find largest clique present in graph

find largest clique present in graph

Explain high-order and low-order bytes., Explain high-order and low-order b...

Explain high-order and low-order bytes. - Numbers are written from left to right in decreasing order of significance. In the same way, bits in a byte of computer memory can be

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd