Question #186971

You

are required to design a software for a vehicle showroom to manage its

activities. Given the following requirements:


 


The showroom has a name, address

and sales tax number. The showroom sells cars and trucks. Car has a

manufacturer, model and number of doors, truck has a manufacturer, model and

loading capacity.

  •  Please decide which classes would be needed and what would be the relationship between those classes.
  •  Write the interface of the classes decided above .

Expert's answer

A base class vehicle with data members such as manufacturer and model. Two derived classes from the vehicle class, car with an additional data member number of doors, and truck, with additional data member loading capacity. A showroom class with data members name, address, and sales tax number. In addition, the showroom class will have cars and trucks.


class Vehicle{
    protected:
        string manufacturer, model;
    public:
        Vehicle(string mf, string mod): manufacturer(mf), model(mod){}
};
class Car: public Vehicle{
    int number_of_doors;
    public:
        Car(string mf, string mod, int n): Vehicle(mf, mod), number_of_doors(n){}
};
class Truck: public Vehicle{
    int loading_capacity;
    public:
        Truck(string mf, string mod, int n): Vehicle(mf, mod), loading_capacity(n){}
};
class Showroom{
    string name, address;
    int sales_tax_number;
    Car *cars;
    Truck *trucks;
    public:
        Showroom(string n, string ad, int st){
            name = n;
            address = ad;
            sales_tax_number = st;
        }
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS