Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++, Will upvote. The following code should compile and run, but the user interface is train wreck. !!!!Please make sure answer each question below!!!!!! A)

C++, Will upvote.

The following code should compile and run, but the user interface is train wreck.

!!!!Please make sure answer each question below!!!!!!

A) Fix the interface so that it makes sense.

B) Make it possible to add and remove cars at the front and back of the train.

C) Improve and add any classes or functions that you see fit.

D) Be sure to write a summary of your work and document the code with sufficient comments

----------------------------------------------

#include

usingnamespacestd; intcurrent_year = 2017; constdoublePI = 3.14159; classcontainer { public: intpercent_loaded; container() { cout << " Calling container default constructor."<< endl; } }; //Syntax: //class subclass_name : public superclass_name { }; classbox : publiccontainer { public: doubleheight, width, length; box() { cout << " Calling box default constructor."<< endl; } doublevolume(){ returnheight * length * width; } }; classcylinder : publiccontainer { public: cylinder(){} cylinder(doublerad, doublelen) {radius = rad; length = len;} doubleradius, length; doublevolume ( ) {returnPI * radius * radius * length;} }; classrail_car { public: intyear_built; rail_car() { cout << " Calling rail_car default constructor."<< endl; } intage() {returncurrent_year - year_built;} }; classbox_car : publicrail_car, publicbox { public: box_car(){ cout << " Calling box_car default constructor."<< endl; height = 10.0; length = 40.0; width = 9.0; } }; classtank_car : publicrail_car, publiccylinder { public: tank_car ( ) : cylinder (3.5, 40.0) { } }; classengine : publicrail_car { public: engine ( ) { } }; classcaboose : publicrail_car { public: caboose ( ) { } }; // ?? rail_car *train[100]; main ( ) { // ?? intcar_count, type_code; // Read type number and create corresponding objects: for(car_count = 0; cin >> type_code; ++car_count) if(type_code == 0) train[car_count] = newengine; elseif(type_code == 1) train[car_count] = newbox_car; elseif(type_code == 2) train[car_count] = newtank_car; elseif(type_code == 3) train[car_count] = newcaboose; // ?? cout << "There are "<< car_count << " cars in the array."<< endl; }

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_2

Step: 3

blur-text-image_3

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

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

Historical Returns: Expected and Required Rates of Return

Answered: 1 week ago