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

Change to palindrome, A palindrome is a string that reads the same from bot...

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 task is to convert S to palindrome

Program to compare the two dates given by the user, THIS PROGRAM IS TO COM...

THIS PROGRAM IS TO COMPARE THE TWO DATES GIVEN BY THE USER #include #include #include struct date  {   int dd;   int mm;   int yy;  }; date compare(date d1,date d2)  {

Explain the goto statement, The goto statement This statement can be us...

The goto statement This statement can be used to branch to another statement of the program. This is rarely used as it violates the principle of structured programming. Though

Define register storage class - computer programming, Define Register Stora...

Define Register Storage Class - computer programming? The Storage class register notify the compiler that the associated variables must be stored in high-speed memory register.

Explain different access specifiers in a class, Question 1 Create a class ...

Question 1 Create a class String which stores a string value. Overload ++ operator which converts the characters of the string to uppercase (toupper() library function of "ctype.h

Program for read a formal expression from standard input, Your program will...

Your program will read two kinds of data from two files: names and predicates. It will read a formal expression from standard input and check whether that expression is syntactical

Explain the loop statements in computer programming, Explain the Loop State...

Explain the Loop Statements in Computer Programming? 1. C gives you a choice of three kinds of loop, while, do while and for. 2. The while loop remain repeating an action until

Java code, Calculate the salary if the person work 8 hours/day and the sala...

Calculate the salary if the person work 8 hours/day and the salary/hour is RM5.20 - UML class diagaram -Class -Exception handling/assertion

Scope resolution operator, what are the significances of scope resolution o...

what are the significances of scope resolution operator? Illustrate with example

Write a program to sum any pair of numbers, Write a C++ program that reads ...

Write a C++ program that reads from keyboard 3 integers, with proper input prompt, and then displays the maximum sum of any pair of numbers from these three. If the 3 numbers are 5

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