Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Writing a new class that is derived from another class.You will be given the code for a Car class. Your job is to write a CustomCar class that is derived from Car and adds new features to it.The existing Car class will allow you to create a specific model of a car, but that car will always be the color black and have no features.

You need to create a CustomCar class. Put the specification for it in the CustomCar.h file and the implementation for it in the CustomCar.cpp file. The CustomCar class should extend the Car class and have the following new features:

  • It will need to have its own constructor. The constructor should simply call the Car constructor and then set the private features variable to be empty. See the book for an example.
  • It will need a SetColor method. This method should simply set the Car's color. The Car's color is a Protected variable. This means that the derived class can change it.
  • It will need a SetFeatures method. This method should set the features in a private variable of the CustomCar class
  • It will need to have a PrintInfo method. This method should call the existing Car PrintInfo method, and then print the features info after that
  • It will need to have a private features variable to store the text of the features

Test 1 checks for the output of the Red color Work on getting this working first.

Test 2 checks for the output of the features. Work on getting this working next.

Driver Program: Paste this into your main.cpp

// YOUR NAME HERE
#include
#include

#include "Car.h"
#include "CustomCar.h"

using namespace std;


Car *theCars[100];
int theCarsCount = 0;

void AddCarToList(Car* car){
    theCars[theCarsCount] = car;
    theCarsCount++;
}

void PrintCarList(){
    for(int i=0; i        theCars[i]->PrintInfo();
}
  

void main()
{
    // Use this code as is:
    
    cout << "Hello World!" << endl;
    Car *carA = new Car("Basic");
    Car *carB = new Car("Model-T");

    CustomCar *carC = new CustomCar("Sporty");
    carC->SetColor("Red");
    carC->SetFeatures("Sun-Roof & Leather Seats");
    
    AddCarToList(carA);
    AddCarToList(carB);
    AddCarToList(carC);
    
    PrintCarList();    

}

Here is the standard car.h class:

#include

#include

using namespace std;

class Car {

public:

Car(string model);virtual void PrintInfo();

protected:

string Model;string Color;};

Here is standard car.cpp:

#include "Car.h"

Car::Car(string model) {

Model = model;

Color = "Black";

}

void Car::PrintInfo() {

cout << "CAR INFO" << endl;

cout << " Model: " << Model << endl;

cout << " Color: " << Color << endl;

}

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9901651

Have any Question?


Related Questions in Computer Engineering

What are some differences between transaction processing

What are some differences between Transaction Processing Information Systems and Management Information Systems?

Question suppose that you are searching an unsorted array

Question : Suppose that you are searching an unsorted array of objects that might contain duplicates. Devise an algorithm that returns a list of the indices of all objects in the array that match a given object. If the d ...

Develop a hypothesis that could explain why a soap created

Develop a hypothesis that could explain why a soap created from the acid CH 3 CH 2 CH 2 CH 2 COOH has poorer cleaning properties than soap made from palmitic acid. Develop a hypothesis that could explain why a soap creat ...

How do you find the mass of solid niso4 x 6h2o i have the

How do you find the mass of solid NiSO4 x 6H2O? I have the molar mass and it is 262.85and I need to find the mass of it. That's what the question is telling me to do.

String problemfor each numerical value 0 1 2 9 0 lt number

String Problem For each numerical value 0, 1, 2, ...9 (0 Print the converted sentence both to the screen and to an output file. Your input file consists of a variable number of records. Each record is a sentence of lengt ...

Briefly explain what separations are how do they effect the

Briefly explain what separations are, how do they effect the average duration of unemployment?

Question subject digital securitywhat do you think about

Question : Subject : Digital Security What do you think about how cloud makes DLP (Data Loss Prevention) more difficult? The response must be typed, single spaced, must be in times new roman font (size 12) and must follo ...

Question you are to write a report on the malware assigned

Question: You are to write a report on the malware assigned to you in the "Week 6 Malware assignment by individual student" document. Your report, written in Microsoft Word with 12 point type and 1 in margins, must have ...

Suppose in your company you formulate a python script that

Suppose in your company you formulate a Python script that inserts, updates, and deletes data in tables in a MySQL database. You post your Python script on a shared drive for other staff members to use. What are some the ...

Question you recently have been hired as the director of

Question: You recently have been hired as the Director of Systems Administration operations for ViralMedia, a provider of software tools for graphics artists. The company's core product, DigiWorld, runs under Windows and ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As