Question: This is a simple c++ class that utilizes inheritance and multiple files (multiple .hpp/.cpp files) Using CourseMember.hpp & CourseMember.cpp, I need to create 3 other
This is a simple c++ class that utilizes inheritance and multiple files (multiple .hpp/.cpp files) Using CourseMember.hpp & CourseMember.cpp, 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_;
-------------------------------------------------------------------
These are the required members for Instructors
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 CourseMember.hpp & CourseMember.cpp below.
//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 "CourseMember.hpp"
#include
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_ */
std::string CourseMember::getFirstName() const {
return first_name_;
}
/** @return returns last_name_ */
std::string CourseMember::getLastName() const {
return last_name_;
} //----------------------------- //End CourseMember.cpp
Thank you!!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
