Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a simple c++ class that utilizes inheritance and multiple files (multiple .hpp/.cpp files) There is one main class, CourseMember(.hpp/.cpp), and I need to

This is a simple c++ class that utilizes inheritance and multiple files (multiple .hpp/.cpp files)

There is one main class, CourseMember(.hpp/.cpp), and I need to create 3 other subclasses from it (Student, Teaching Assistant, and instructor)

Both Students and Instructors are CourseMembers. A TeachingAssistant is not only a CourseMember but also a Student. Thus the inheritance structure will be as follows: Student will be a derived class of CourseMember. TeachingAssistant will be a derived class of Student. Instructor will be a derived class of CourseMember.

Please do not add or remove any member functions.

---------------------------------------------------------------------

These are the required members for Student.

class Student public members: Student(int id, std::string first, std::string last);

std::string getMajor() const;

double getGpa() const;

void setMajor(const std::string major);

void setGpa(const double gpa);

class Student protected members: std::string major_; double gpa_;

---------------------------------------------------------------------------------------------------------

These are the required members for teaching assistant.

class TeachingAssistant auxiliary types:

The TeachingAssistant class uses an enum (a user-defined data type) to keep track of the specific role the TA has: enum ta_role {LAB_ASSISTANT, LECTURE_ASSISTANT, BOTH};

You may assume for initialization purposes that the default role is LAB_ASSISTANT.

class TeachingAssistant public members: TeachingAssistant(int id, std::string first, std::string last);

int getHours() const;

ta_role getRole() const;

void setHours(const int hours);

void setRole(const ta_role role);

class TeachingAssistant private members:

int hours_per_week_;

ta_role role_;

-------------------------------------------------------------------

class Instructor public members:

Instructor(int id, std::string first, std::string last);

std::string getOffice() const;

std::string getContact() const;

void setOffice(const std::string office);

void setContact(const std::string contact);

class Instructor private members:

std::string office_;

std::string contact_;

-----------------------------------------------------------------

Here is the main class.

//CourseMember.hpp

//----------------------------

#ifndef CourseMember_hpp #define CourseMember_hpp

#include

class CourseMember { public: /** Parameterized constructor @param id the student's unique identifier @param first the student's first name @param last the student's last name */ CourseMember(int id, std::string first, std::string last);

//********** Accessor Methods ****************

/** @return returns id_; */ int getID() const;

/** @return returns first_name_ */ std::string getFirstName() const;

/** @return returns last_name_ */ std::string getLastName() const;

private: int id_; /** the CourseMember's ID */ std::string first_name_; /** the CourseMember's first name */ std::string last_name_; /** the CourseMember's last name */

}; //end CourseMember

#endif /* CourseMember_hpp */

//-------------------

//CourseMember.cpp

//-----------

#include #include "CourseMember.hpp" #include using namespace std;

CourseMember::CourseMember(int id, std::string first, std::string last) { id_ = id; first_name_ = first; last_name_ = last; }

//Return ID int CourseMember::getID() const { return id_; }

/** @return returns first_name_ */ string CourseMember::getFirstName() const { return first_name_; }

/** @return returns last_name_ */ string CourseMember::getLastName() const { return last_name_; }

//-----------------------------

Thank You

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions