Page 1 of 1

In C++ please. Thank You

Posted: Fri Jul 01, 2022 5:37 am
by answerhappygod
In C++ please. Thank You
In C Please Thank You 1
In C Please Thank You 1 (156.84 KiB) Viewed 32 times
3. (35 pts) We will be designing a management system for a national train system (think: Amtrak)! Our trains are made up of many cars, each of which could be a passenger car, or a cargo car. On any train, it is important that we know the weight of the train so as to be able to plan for fuel needed and stopping distances. Cargo cars have to account for the weight of all the cargo contained in them but passenger cars can make an estimate as to their weight based on the number of passengers multiplied by the weight of an "average" passenger (currently 220 pounds, including baggage). Please design the following classes and functions keeping in mind the restrictions above and below ● Train. This class will store all of the cars in a vector and will have the following functions: i. an "addCar" function which adds one of the car types below ii. an "getTotalWeight" function which gets the total weight of all cars on the train CargoCar. This class will store information about all of the cargo contained in the car. It will have the following functions: i. An "addPackage" function which will take a double, the weight of the cargo to be added to this car ii. A "getWeight" function which returns the total weight of the car (the sum of all packages) PassengerCar. This class will store the number of passengers in the car. It will have the following functions: i. Overloaded ++ and -- operators (all of them) which will increase and decrease the number of passengers in the car ii. A "getWeight" function which returns the total weight of the car (the number of passengers multiplied by 220). ● ● Notes: A main that creates a train with two passenger cars and a cargo car, adds a 1500 pound package to the CargoCar, adds a passenger to each of the PassengerCars and then prints the total weight of the train to the screen. ● ● Use vectors to make your life easier! You may inline functions as long as they do not exceed one line of code Remember to use const where appropriate!