Program needs to be in C++ The program will have a person, student, and faculty class. Use an STL for a list rather than using the "list" class. Populate an STL structure with a series of objects (at...





Program needs to be in C++


The program will have a person, student, and faculty class. Use an STL for a list rather than using the "list" class. Populate an STL structure with a series of objects (at least 5 combined). Create a list of POINTERS to objects, so you can use polymorphism. The beginning of the list should be all faculty (add to the head), and the end of the list (add at the tail) should be students/interns. It is not necessary to add the base class objects. Utilize the STL functions to apply: add student/intern/faculty, remove a specific entry from a user input of a name, search for name, print all, and delete all. The menu items will be in main and call the STL functions.


Please use the code below and make the appropriate edits


#include
#include
using namespace std;


struct Date {
    int month, year;
};


class Person {
protected:
    string name, department;
public:
    Person() {
        name = "";
        department = "";
    }
    Person(string n, string d) {
        name = n, department = d;
    }
    void print() {
        cout < "name:="" "="">< name=""><>
        cout < "department:="" "="">< department=""><>
    }
    string getName() {
        return name;
    }
    string getDepartment() {
        return department;
    }
    ~Person() {
        cout <>
    }
};


class Student : public Person {
protected:
    Date graduationDate;
public:
    Student() {
        graduationDate.month = 0;
        graduationDate.year = 0;
    }
    Student(string n, string d, Date date) {
        name = n, department = d;
        graduationDate = date;
    }
    void setGraduationDate(Date d) {
        graduationDate = d;
    }
    Date getGraduationDate() {
        return graduationDate;
    }
    int timeToGraduation(Date today) {
        if (today.month > graduationDate.month) {
            return ((graduationDate.year - today.year - 1) * 12 +
                (12 - today.month) + graduationDate.month);
        }
        else {
            return ((graduationDate.year - today.year) * 12 +
                abs(today.month - graduationDate.month));
        }
    }
    void print() {
        cout < "name:="" "="">< name=""><>
        cout < "department:="" "="">< department=""><>
        cout < "graduation="" date:="" "="">< graduationdate.month="">< "/"="">< graduationdate.year=""><>
    }
};


class Faculty : public Person {
protected:
    Date startDate;
    string title;
public:
    Faculty(string n, string d, string t, Date date) {
        name = n, department = d, title = t;
        startDate = date;
    }
    void setTitle(string t) {
        title = t;
    }
    void setStartDate(Date d) {
        startDate = d;
    }
    string getTitle() {
        return title;
    }
    Date getStartDate() {
        return startDate;
    }
    void print() {
        cout < "name:="" "="">< name=""><>
        cout < "department:="" "="">< department=""><>
        cout < "title:="" "="">< title=""><>
        cout < "start="" date:="" "="">< startdate.month="">< "/"="">< startdate.year=""><>
    }
};


class Intern : public Student {
protected:
    string company;
    double salary;
public:
    Intern(string n, string d, Date date, string c, double s) {
        name = n, department = d;
        graduationDate = date;
        company = c;
        salary = s;
    }
    void setSalary(double s) {
        salary = s;
    }
    void setCompany(string c) {
        company = c;
    }
    string getCompany() {
        return company;
    }
    double getSalary() {
        return salary;
    }
    void print() {
        cout < "name:="" "="">< name=""><>
        cout < "department:="" "="">< department=""><>
        cout < "company:="" "="">< company=""><>
        cout < "salary:="" "="">< salary=""><>
        cout < "graduation="" date:="" "="">< graduationdate.month="">< "/"="">< graduationdate.year=""><>
    }
};


int main() {
    Date today, graduation;
    today.month = 3;
    today.year = 2021;
    graduation.month = 10;
    graduation.year = 2027;


    Student John("John Smith", "Computer Science", graduation);
    Faculty Chris("Chris Smith", "Computer Science", "Associate Professor", today);
    Intern Bob("Bob Smith", "Computer Science", graduation, "Apple", 60000.0);


    Student* studentArray = new Student[10];


    John.print();
    cout < "time="" for="" john="" to="" graduate:="" "="">< john.timetograduation(today)="">< "="">
    cout <>
    Chris.print();
    cout <>
    Bob.print();
    cout < "time="" for="" bob="" to="" graduate:="" "="">< bob.timetograduation(today)="">< "="">
    return 0;
}


Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here