Code in C Using inheritance AND composition create a program

Code in C++

Using inheritance AND composition create a program to incorporate the following data members into the following classes appropriately.

Data members: price (float), company name (string), memory (int), display size (float), watts (int)

          Electronics

          Manufacturer

          TV

          Computer

          Receiver

          1. Comply with the DRY principle (look for repeated data).

          2. Instantiate and initialize an object of type TV.

          3. Display ALL the appropriate information for the object.

Solution

#include using namespace std; class tv { public: string companyname; int memory; int watts; float prize; float displaysize; tv(): companyname(\"onida\"), memory(16), price(45000.00) ,watts(240) { } public : void display() { cout << \"companyname:\" << companyname << endl; cout << \"memory:\" << memory << endl; cout << \"price:\" << price << endl; cout << \"watts:\" << watts << endl; } }; class Electronics : public tv { public: void display() { tv :: display }; }; class Manufacturer : public tv { void display() { tv :: display }; } class computer : public tv { void display() { tv :: display }; } class reciever : public tv { void display() { tv :: display }; } int main() { Electronics er; er.companyname = \"Exide\"; er.watts = 240; er.memory =40; er.price = 100000.00; er.display(); Tv tv1; tv1.display(); Manufacturer sr; sr.companyname = \"milton\"; sr.watts = 240; sr.memory =30; sr.price = 10000.00; sr.display(); computer dr; dr.companyname = \"hp\"; dr.watts = 230; dr.memory =20; dr.price = 10000.00; dr.display(); Reciever rr; rr.companyname = \"hcl\"; rr.watts = 240; rr.memory =10; rr.price = 20000.00; rr.display(); return 0; }
Code in C++ Using inheritance AND composition create a program to incorporate the following data members into the following classes appropriately. Data members:

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site