Question: In this lab, we will declare a class, called Inventory. The class has 4 private attributes: quant, reorder, price and description. The Inventory class also

In this lab, we will declare a class, called Inventory. The class has 4 private attributes: quant, reorder, price and description. The Inventory class also include the following methods (behaviors): constructor, destructor, print, getQuant, getReorder and getPrice. The header file and the implementation file are listed below:

The declaration of Inventory is:

 // file name: Inventory.h #ifndef H_INVENTORY #define h_INVENTORY #include  
 using namespace std; class Inventory { 
 private: int quant; 
 int reorder; double price; string descrip; 

public:

// number on hand // reorder quantity // price per unit // description of item 
 Inventory (int q, int r, double p, string d); 
 ~Inventory(); void print(); int get_quant(); int get_reorder(); double get_price(); 

};

#endif

The implementation of Inventory is as the following:

// file name: InventoryImp.cpp #include #include "Inventory.h" using namespace std; Inventory::Inventory (int anyQuam, int anyReorder, double anyPrice, string

 anyDescrip) { quant = anyQuam; reorder = anyReorder; price = anyPrice; descrip = anyDescrip; 
 } Inventory::~Inventory() { } void Inventory::print() { 
 cout <<"Description: " << descrip << endl; } 
 int Inventory::get_quant() { return quant; 
 } int Inventory::get_reorder() { 
 return reorder; } 
 double Inventory::get_price() { return price; 

}

The following is a test program that uses the Inventory class:

 // file name: testInventory.cpp #include  #include "Inventory.h" using namespace std; 

int main() { Inventory first200(200, 2, 20.25, "some parts"); first200.print(); return 0;

}

Open Dev C++, create a project, named InventoryProj. Add all three files to the project.

Correct all errors in the source files and run the program.

3. The output showed only the description of the first200 object. Modify the Inventory class so that the output will display all parts of the first200 object.

Now, we will derive 2 subclasses out of Inventory.

 // // first derived class // using namespace std; class Auto , public Inventory { 
 private string manufacturer; 
 public: Auto (int q, int r, double p, string d, string man); 
 ~Auto(); void print(); string getManufacturer(); 

}

Auto::Auto (int anyQuan, int anyReorder, double anyPrice, string anyDescrip, string nayManufactureer)

: Inventory(anyQuan, anyReorder, anyPrice, anyDescrip) {

 // calls base constructor manufacturer = nayManufactureer 
 } ~Auto() { } void Auto::print() { 
 cout << setiosflags (ios::fixed); 
 cout << "Manufacturer: " << manufacturer << endl; } 
 string getManufacturer() { return manufacturer; 

}

 // // Second derived class // #ifndef H_TRANSMISSION #define H_TRANSMISSION class Transmission : public Inventory { 

private:

 string vendor; public: 

Transmission (int q, int r, double p, string d, string ven); ~ Transmission (); void print(); string getVendor() const;

};

Transmission::Transmission (int anyQuamt, int anyReorder, double anyPrice, string anyDescrip, string anyVendor) {

 vendor = anyVendor; } 
 Transmission::~Transmission () { } void Transmission::print() { 
 cout << setiosflags(ios::fixed); 
 cout << "Vendor: " << vendor << endl; } 
 string Transmission::getVendor() { return vendor; 

}

Add these files to your project.

Write a main () function that creates an instance object of Auto called Car, which has the following

initial data: there is a quantity of five(5) on inventory, and two(2) on reorder; the price per unit is $15,545.91, and the description is that of a four-wheel drive truck, obtained from the GM. Initialize the object Car, and print out all its vital facts.

A Transmission is purchased from Aztec Inc., and must be inventoried. There are 25 of them, with 10 more on reorder. Their price is $1789.98. Instantiate and initialize an object for Transmission (called, interestingly enough, Transmissions), and provide the same information.

Print the two objects.

Compile the program and correct all errors in the program and run it. (each group member should

help out to each other)

Your output should look like the following:

Note: the output does not really print the entire attributes of each object. Please note that the print() functions has been overwritten in the derived class, so if the print() for the base class is desired, it must be specified. Precede all printouts with a line describing what it is we are looking at. Correct the print function and run the program again. \Before you submit, zip the entire project folder to an .zip file (you may use 7-zip as you wish). Name your zip file as: inheritanceFirstInitialLastname(1)FirstInitialLastName(2).zip. Submit the zip file to Blackboard.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!