Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1. Create a classes to construct a car the with an engine, following the requirements in the Note. Please declare classes in Q1.h and test

Q1. Create a classes to construct a car the with an engine, following the requirements in the Note. Please declare classes in Q1.h and test the classes (create objects and call member functions) in Q1.cpp.

Note: Create a class named Engine it has features of weight and engine size; the weight is set to fixed value 30 pbl (using static const), and the engine size should be non-static const. It also has a regular member variable status, which has accelerating, decelerating, idle, stopped status (using enum) define two constructors one is default and another with an argument for engine size (float); both constructors should do initialization in the constructor initializer list define three member functions readWeight, readSize, and readStatus to return the above defined member variables, respectively; also, define a member function start which starts the engine (set status to idle)

Create a class named Car it has features of passagers_in_Car (integer) and weight (float), and an engine (using composition from Engine); weight can be protected define a constructor that has an argument for engine size (float); the constructor should initialize engine size and weight in its initializer list. define member functions readWeight, start, and takePassengers, which: returns the weight of the car, starts he car (the engine), and takes passengers (increase the value of passengers_in_Car), respectively; also define a report member function print the values of the member variables engine size, passengers, weight, and engine states.

Write a main function, create an object car1 with 4.7 L engine size, call report, take in 3 passengers, call start, and report again.

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

More Books

Students also viewed these Databases questions