Answer to Question #211359 in C++ for osama

Question #211359

Consider

Class Department:

Class Sector:

• A two-argument constructor to initialize data fields with user-defined values

• A member function display() to show all attribute values

Class Laboratory:

• 3 attributes labID, access_level, sectID , experimentNo

• A three-argument constructor that Initializes labID and experimentNo with user-defined values

Class Person:

• A parameterized constructor to initialize attributes with user-defined values

• A member function display() to show its attribute values

Class Scientist from Person:

• A data field named sciName of type string

• A data field named dept of type Department

• A data field named designation of type string

• A two-argument constructor to initialize both attributes of user-defined values

Class Engineer from Person:

• A constructor to initialize lab with user-defined value


Implement all classes while illustrating concept of aggregation , composition in terms of ownership , life-cycle.


1
Expert's answer
2021-06-28T07:24:13-0400
#include <iostream>
#include <string>
using namespace std;
class Department{
    public:
    Department(){}
};
class Sector{
    protected:
    string secName, secID;
    public:
    Sector(string a, string b):secName(a), secID(b){}
    void display(){
        cout<<"Sector Name: "<<secName<<endl;
        cout<<"Sector ID: "<<secID<<endl;
    }
};
class Laboratory{
    protected:
    string labID, access_level, sectID , experimentNo;
    public:
    Laboratory(string labID, string experimentNo, string accessLevel){
        this->labID = labID;
        this->experimentNo = experimentNo;
        this->access_level = accessLevel;
    }
};
class Person{
    protected:
    string name;
    int age, id;
    public:
    Person(string name, int age, int id){
        this->name = name;
        this->age = age;
        this->id = id;
    }
};
class Scientist:public Person{
    string sciName, designation;
    Department dept;
    public:
    Scientist(string name, int age, int id, string sciName, string designation):Person(name, age, id){
        this->sciName = sciName;
        this->designation = designation;
    }
};
class Engineer:public Person{
    Laboratory lab;
    public:
    Engineer(string name, int age, int id, string labID, string experimentNo, string accessLevel):
        Person(name, age, id), lab(labID, experimentNo, accessLevel){}
};

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS