Answered step by step
Verified Expert Solution
Question
1 Approved Answer
language is c++ ****below is the test program to test the class****** #include #include #include #include #include #include // uncomment the following lines to test
language is c++ ****below is the test program to test the class****** #include3) Instructor Student Problem (Polymorphism) Define a Person class with the following class variables string name and address. For methods it should have a default constructor that sets both variables to the empty string. It should have an overloaded constructor that takes parameters for all variables. Each variable should have a setter and a getter. There should be a method getjob that is hard coded to return the string "undefined". Define a class Instructor that is a Person. It should add the variable Office hours (a string) with setter and getter. It has a method getJob that is hard coded to return the string "instructor". Define a class Student that is a Person. It should add the variable GPA which is a float along with setter and getter. It has a method getJob that is hard coded to return the string "student". Use the test program in main to test your class#include #include #include #include #include // uncomment the following lines to test your project #define testInstruct #define testStudent #define testJob #include "Instructor.hpp" #include "Student.hpp" using std::string, std::cout, std::endl, std::setw; void makePersonInfo(string &name, string & address); string makeHours(); float makeGPA(); int main() { unsigned int seed = static_cast (time(nullptr)); srand(seed); string name, address; const int NAMELEN = 15, ADDLEN = 15; #ifdef testInstruct cout getName(); address = theInstructors[i]->getAddress(); officeHrs = theInstructors[i]->getOfficeHours(); cout getName(); address = theStudents[i]->getAddress(); gpa = theStudents[i]->getGPA(); cout getName() getAddress() getJob() (rand()%100)/100.0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started