Question
Based on: #include #include using namespace std; class Asset { public: Asset(string manN, string pda, float co); void getAsset(); //Data Members protected: string Manufacture, purchaseDate;
Based on:
#include
using namespace std;
class Asset { public: Asset(string manN, string pda, float co); void getAsset();
//Data Members protected: string Manufacture, purchaseDate;
private: float cost; };
//Instantiation Asset::Asset(string manN, string pda, float co) :Manufacture(manN), purchaseDate(pda), cost(co) {}
//Asset printed details void Asset::getAsset() { cout << "Asset manufacturer name:" << Manufacture << endl; cout << "Asset purchage date:" << purchaseDate << endl; cout << "Asset cost:" << cost << endl; }
//Hardware class inheriting from Asset class Hardware : public Asset { public: Hardware(string mn, string pd, float cos, string mod); void getHardware();
//Data Members private: string model; };
Hardware::Hardware(string mn, string pd, float cos, string mod) :Asset(mn, pd, cos), model(mod) {}
//Member function of hardware void Hardware::getHardware() { cout << "detalis of hardware" << endl; getAsset();//this is from baseclass Asset, we got it via inheritance cout << "Hardware model name:" << model << endl; }
//Software class inheriting from Hardware class Software : public Hardware { public: Software(string mn, string pd, float cos, string mo, string ti); void getSoftware();
//Data Members protected: string title; };
Software::Software(string mn, string pd, float cos, string mo, string ti) :Hardware(mn, pd, cos, mo), title(ti) {}
//Member function of Software void Software::getSoftware() { cout << "Details of Software" << endl; getAsset();//this is from baseclass Asset, we got it via inheritance cout << "software title:" << title << endl; }
int main() { //Data declaration string manufacture, date, model, title; float cost;
//Input cout << "Enter details of hardware" << endl; cout << "Enter manufacturer name , purchased date ,cost and model: " << endl; cin >> manufacture >> date >> cost >> model;
cout << "Now we are goining to instanciate Laptop" << endl; //Implementation Hardware o1(manufacture, date, cost, model); o1.getHardware(); //Input cout << "Enter details of software" << endl; cout << "Enter manufacturer name , purchased date ,cost and title: " << endl; cin >> manufacture >> date >> cost >> model >> title;
cout << "Now we are goining to instanciate software" << endl; //Implementation Software o2(manufacture, date, cost, model, title); o2.getSoftware(); }
Add the following for the Asset hierarchy
Cubicle Data members - area (float to represent sq. feet) - length (float) - width (float) Chair Data members - office number (int) Laptop Data members - O/S (string) - memory (int) - screen size (float) Server Data members - O/S (string) - memory (int) 1. Fix the hierarchy to comply with the DRY principle (look for repeated data). 2. Instantiate and initialize an object of type Cubicle and Laptop. 3. Display ALL the appropriate information for the object using getters.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started