Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++(Hardware is derived from Asset) Create an inheritance hierarchy for Asset /

ID: 3813902 • Letter: C

Question

C++(Hardware is derived from Asset)

Create an inheritance hierarchy for

Asset / Furniture / Hardware / Software / Cubicle / Chair / Server / Laptop

Asset

Data members

- manufacturer

- purchase date

- cost

Hardware

Data members

- model Software Data members

- title

1. Instantiate an object for each type: Chair, Laptop, Software.

- Initialize at time of instantiation.

2. Provide data to initialize the data members of the objects.

3. use getter functions to display all the data associated with each of the objects.

Note: You won't instantiate objects for all the classes in the inheritance hierarchy but you still need to make sure all the classes are complete.

Explanation / Answer

#include<iostream>
#include<cstring>
using namespace std;
class Asset
{
   private:
       std::string manufacturer;
       std::string purchase_date;
       double cost;
   public:
       void set_cost(double cost){
           this->cost=cost;
       }
       void set_purchase_date(std::string purchase_date){
           this->purchase_date=purchase_date;
       }
       void set_manufacturer(std::string manufacturer){
           this->manufacturer=manufacturer;
       }
       std::string get_manufacturer(){
           return this->manufacturer;
       }
       std::string get_purchase_date(){
           return this->purchase_date;
       }
       double get_cost(){
           return this->cost;
       }
};
class Furniture:public Asset
{
  
};
class Software:public Asset{
   private:
       std::string title;
   public:
       void set_title(std::string title){
           this->title=title;
       }
       std::string get_title(){
           return this->title;
       }
};
class Hardware:public Asset{
   private:
       std::string model;
   public:
       void set_model(std::string model){
           this->model=model;
       }
       std::string get_model(){
           return this->model;
       }
};
class Cubicle:public Furniture{
  
};
class Chair:public Furniture{
  
};
class Server:public Hardware{
  
};
class Laptop:public Hardware{
  
};
int main(){
   Chair c;
   c.set_cost(1000.0);
   c.set_manufacturer("godrej");
   c.set_purchase_date("12/04/17");
   Server s;
   s.set_cost(20000.0);
   s.set_manufacturer("lenovo");
   s.set_model("g500");
   s.set_purchase_date("11/03/17");
   Laptop l;
   l.set_cost(30000.0);
   l.set_manufacturer("lenovo");
   l.set_model("g500");
   l.set_purchase_date("10/03/17");
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote