Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Section 3: Multi-File Classes Consider the following code for a car dealership. a) (5 points) Write in the necessary quards, preprocessor directives (Hinclude, fendi, #define.

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Section 3: Multi-File Classes Consider the following code for a car dealership. a) (5 points) Write in the necessary quards, preprocessor directives (Hinclude, fendi, #define. #ifndef) and forward declarations to compile this multi-file program. Car.h Car.app inelude Cariicar (std: istring nake (r code not shown tcode not sbown std:sstring Car::getHake )const stdi istring Car: :getModel 0 eonst atdsistring model) private stdristringake atd::stringodel; double earnedonCari public: Car (stdiistring, stdi istring) : std ::string getHake() oonst std:istring gotMode1 ) const: returnake: return nodel: // Deale // Dealership.cpp #dthe DEALERS! 1P.H void Dealership::swapCars (int posl, t code not shown void Dealership::gettotalsales eonst t const int HXONUNCARS100; int pos2) class Dealership private: double sun -o void swapCars (int posl, int pos2) Dealership(const Dealership ) void updata Tovntory (doubie inib) su cars[4]-> publie return sun e getTotalSales ) const addCar (Car*) /I Other member functions not shown // Rest of class not shown 1i eh // main.cP..a int main) Car e("Ford"Mustang") Dealership d // Rest of code not shown b) (2 points) Write the Car member function definition for double getAmountEarnedonCar) const: It returns the amount the car has earned. c) (5 points) Write the Dealership member function definition for void updateInventory (double limit); It appropriately removes any Car object whose earnings are less than limit function should use the private member function . The void swapCars (int posl, int pos2) which swaps the cars pointed to at positions pos1 and pos2. to points) There are a number of Dealership stores opening, so a decision is made that when a car is created, it should be passed a pointer to its dealership along with its make and model. It should store the dealership pointer in an appropriate data member declarations in the space provided. d) Write the data member and necessary constructor class Car f private: string m make: string m model double m earningsOnCari public: Car (string make, string model) : double getEarnings () const: Write the constructor definition for creating a Car. In the constructor you shou use the Dealership member function void addCar (Car*) to add the car to its dealership. e) (5 points) At some point, once a lot of Dealership stores have been created, it be comes easier to just create clones of the Dealership stores. Write the copy constructor for creating a Dealership: Section 3: Multi-File Classes Consider the following code for a car dealership. a) (5 points) Write in the necessary quards, preprocessor directives (Hinclude, fendi, #define. #ifndef) and forward declarations to compile this multi-file program. Car.h Car.app inelude Cariicar (std: istring nake (r code not shown tcode not sbown std:sstring Car::getHake )const stdi istring Car: :getModel 0 eonst atdsistring model) private stdristringake atd::stringodel; double earnedonCari public: Car (stdiistring, stdi istring) : std ::string getHake() oonst std:istring gotMode1 ) const: returnake: return nodel: // Deale // Dealership.cpp #dthe DEALERS! 1P.H void Dealership::swapCars (int posl, t code not shown void Dealership::gettotalsales eonst t const int HXONUNCARS100; int pos2) class Dealership private: double sun -o void swapCars (int posl, int pos2) Dealership(const Dealership ) void updata Tovntory (doubie inib) su cars[4]-> publie return sun e getTotalSales ) const addCar (Car*) /I Other member functions not shown // Rest of class not shown 1i eh // main.cP..a int main) Car e("Ford"Mustang") Dealership d // Rest of code not shown b) (2 points) Write the Car member function definition for double getAmountEarnedonCar) const: It returns the amount the car has earned. c) (5 points) Write the Dealership member function definition for void updateInventory (double limit); It appropriately removes any Car object whose earnings are less than limit function should use the private member function . The void swapCars (int posl, int pos2) which swaps the cars pointed to at positions pos1 and pos2. to points) There are a number of Dealership stores opening, so a decision is made that when a car is created, it should be passed a pointer to its dealership along with its make and model. It should store the dealership pointer in an appropriate data member declarations in the space provided. d) Write the data member and necessary constructor class Car f private: string m make: string m model double m earningsOnCari public: Car (string make, string model) : double getEarnings () const: Write the constructor definition for creating a Car. In the constructor you shou use the Dealership member function void addCar (Car*) to add the car to its dealership. e) (5 points) At some point, once a lot of Dealership stores have been created, it be comes easier to just create clones of the Dealership stores. Write the copy constructor for creating a Dealership

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

What is the purpose of corrected Rand index?

Answered: 1 week ago

Question

Have ground rules been established for the team?

Answered: 1 week ago

Question

a. How are members selected to join the team?

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago