Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CAN YOU POST YOUR ANSWER IN THE FIRST STEP? No other steps are showing up for me. **IMPORTANT - PLEASE USE TEMPLATES WHEN CREATING TRAIN.CPP

CAN YOU POST YOUR ANSWER IN THE FIRST STEP? No other steps are showing up for me.

**IMPORTANT - PLEASE USE TEMPLATES WHEN CREATING TRAIN.CPP AND BUS.CPP**

** I JUST NEED MAIN.cpp, TRAIN.CPP, TRAIN.h, BUS.cpp and BUS.H**

The train .h and bus.h should look something like this-

image text in transcribed

NOTE: IT SHOULD USE TEMPLATES, INTERFACES, AND OPERATOR OVERLOADING!!

1. "a train and a bus must be able to store items of any type" - TEMPLATE

2. Trains and buses are "transporters". Any transporter MUST be able to be loaded with one item, unloaded with one item, empty-ed of all items, moved. They must also be able to report back whether or not they are empty and how many items they are carrying. - INTERFACE

3. people on the bus should "sit" from shortest to tallest - OPERATOR OVERLOADING

4. "a train must be able to report on the weight of all its cargo" - OPERATOR OVERLOADING

PROMPT-

Moving and shaking! We're going to create a program that moves trains carrying cargo and buses carrying people.

Trains and buses are "transporters". Any transporter MUST be able to be loaded with one item, unloaded with one item, empty-ed of all items, moved. They must also be able to report back whether or not they are empty and how many items they are carrying.

Additionally while a train and a bus must be able to store items of any type, in this project a train should store cargo and a bus should transport people. When cargo is loaded onto a train, it doesn't matter where it goes but people on the bus should "sit" from shortest to tallest. Also, a train must be able to report on the weight of all its cargo and a bus must be able to change its fair and give the total fair for all the people on the bus. When a train moves, it can display that it's reached the next destination. When a bus moves, it can display that it's reached the next stop.

Finally, each cargo must have a type and a weight and each person must have a name and a height.

The main driver of your program must create a train and load it with some cargo. It must also create a bus and let people board. All console input and output should occur in the main function (except for what's displayed in the move functions).

image text in transcribed

My CARGO.h looks like-

image text in transcribed

Cargo.cpp-

image text in transcribed

people.h-

image text in transcribed

people.cpp-

image text in transcribed

transportorter.h-

image text in transcribed

E cargo.CF 5 5 SOURCE CONTROL E 21 O... ih M C transporters.h C train.h C train.h>... Message (Ctrl+Enter to commit on'. 1 #ifndef TRAIN_H Changes 2 #define TRAIN_H e bus.cpp M 3 C bus.h M 4 #include 5 G+ people.cpp #include M 6 #include C people.h M 7 #include "transporters.h" C+ train.cpp 02+M #include "cargo.h" 9 using namespace std; 10 11 template 12 class Train : public Transporters{ 13 private: m in on 8 w N 1. Review C++ 2. Review Templates 3. Review Interfaces 4. Review Operator Overloading 5. Review makefiles A Program Moving and shaking. We're going to create a program that moves trains carrying cargo and buses carrying people. Trains and buses are "transporters". Any transporter MUST be able to be loaded with one item unloaded with one item empty-ed of all items, moved. They must also be able to report back whether or not they are empty and how many items they are carrying. Additionally while a train and a bus must be able to store items of any type, in this project a train should store cargo and a bus should transport people. When cargo is loaded onto a train, it doesn't matter where it goes but people on the bus should "sit" from shortest to tallest. Also, a train must be able to report on the weight of all its cargo and a bus must be able to change its fair and give the total fair for all the people on the bus. When a train moves, it can display that it's reached the next destination. When a bus moves, it can display that it's reached the next stop. Finally, each cargo must have a type and a weight and each person must have a name and a height The main driver of your program must create a train and load it with some cargo. It must also create a bus and let people board. All console input and output should occur in the main function (except for what's displayed in the move functions) A MAKEFILE IS REQUIRED 1 #ifndef CARGO_H #define CARGO_H 2 3 4 #include #include 5 6 7 using namespace std; 8 10 class Cargo{ private: string type; float weight; 11 12 13 14 15 15 17 public: Cargo(); Cargo (string, float); Cargo (const Cargo&): void setType(string); void setweight(float): float getweight const; string gettype const; 1. 2 Tend 1 #include "cargo.h" 2 3 4 5 Cargo::Cargo () { type = ""; weight = 0; } 6 7 8 9 10 Cargor:Cargo(string newType, float newWeight) { setType(newType); setWeight(newweight); ) 11 12 13 argot finisse 14 15 Cargo::Cargo(const Cargodhs) { type = rhs.type; weight = rhs.weight; ) 16 17 18 19 20 21 float Cargo: getWeight() const { return weight; } string Cargo::getType() const { return type: 3 22 OHNSON 23 24 25 26 27 28 void cargortsetType(string newlype) { type - newtype; 3 void cargo setweight (float newweight) { weight = newweight; 29 30 31 1 #ifndef PEOPLE_H #define PEOPLE_H 2 3 4 #include #include 5 6 7 using namespace std; 8 9 10 class People private: I string name; float height; 11 12 13 14 1.5 16 1 public: Peoples People(string, float): People(const People&); void setName(string): void setHeight (float): string getName() const; float getHeight const; 18 22 Te #include "people.h" People::People() { name = height @; 5 6 } People::People(string newName, float newHeight) { setName(newName); setHeight(newHeight); } 8 9 @ 11 2 3 14 15 16 17 = People::People(const People& rhs) { height rhs.height; name = nhs.name; ) 18 19 string People: getkame() const { return name; } float People getHeight() const{ return height; 1 20 21 22 23 24 25 26 22 void people::setHeight(float newheight) height = newHeight; } void People : setName(string newName) name = newate; 28 20 1 #ifndef TRANSPORTER_H #define TRANSPORTER H 3 4 #include #include 5. 6 using namespace std; 8. 11 14 class Transporters public: virtual void load() = 0; virtual void unload() = 9; virtual void emptyAllItems() = 8; virtual void sEmpty() = 0; virtual void itemcount() = 0; virtual void lodPeople() = 0; Ivirtual void unloadPeople() = 0; virtual void emeyAll People ( ) = 0; virtual void peopleCount() = e: 16 2 ter

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo

1st Edition

0763733148, 978-0763733148

More Books

Students also viewed these Databases questions