Question: I have to implement a set of classes using inheritance and composition, the classes can be seen below. I know this class is pretty big
I have to implement a set of classes using inheritance and composition, the classes can be seen below. I know this class is pretty big so if I could just get a pseudo code of how to approach each class Id be very grateful.
class person
{
public :
person ();
person ( string , string , string );
string getFirst () const ;
string getLast () const ;
string getId () const ;
private :
string first ;
string last ;
string id ;
};
class student
{
public :
static const int CREDITS_NEEDED = 15;
student ();
student ( string , string , string );
person getPersonInfo () const ;
unsigned int getCredits () const ;
double getGpa () const ;
void addCredits ( unsigned int , double );
bool graduated () const ;
private :
person info ;
unsigned int credits ;
double gpa ;
};
1
class undergrad : student
{
public :
undergrad ();
undergrad ( string , string , string );
string getFirst () const ;
string getLast () const ;
unsigned int getCredits () const ;
double getGpa () const ;
bool searchById ( string ) const ;
bool searchByName ( string ) const ;
void completedClass ( double );
bool graduated () const ;
};
class grad : student
{
public :
grad ();
grad ( string , string , string , string );
string getFirst () const ;
string getLast () const ;
unsigned int getCredits () const ;
double getGpa () const ;
bool searchById ( string ) const ;
bool searchByName ( string ) const ;
void completedClass ( double );
bool graduated () const ;
void completedThesis ();
bool hasDefended () const ;
private :
string thesis ;
bool defended ;
};
class phd : student
{
public :
phd ();
phd ( string , string , string , string );
string getFirst () const ;
string getLast () const ;
unsigned int getCredits () const ;
double getGpa () const ;
bool searchById ( string ) const ;
bool searchByName ( string ) const ;
void completedClass ( double );
bool graduated () const ;
void completedDissertation ();
bool hasDefended () const ;
private :
string dissertation ;
bool defended ;
};
As always, you cannot modify the class, you need to implement those functions as instructed and you cannot change the inheritance type, you can have extra helper (non member) functions in main or in the class implementation file, as always please comment your code (as well as the member functions) and use constants rather than literals as needed
Example Run
Enter Student ID or full name or q to quit : 3451
Star , Patrick
GPA : 3.4 Credits : 3
Graduated : No
Has the student completed a course ? ( Yes or No ): yes
Enter updated GPA : 3.6
Enter Student ID or full name or q to quit : patrick star
Star , Patrick
GPA : 3.6 Credits : 6
Graduated : No
Has the student completed a course ? ( Yes or No ): yes
Enter updated GPA : 3.3
Here is some of the data used
John Smith 1234 U
Patrick Star 3451 U
Not Sure 1111 P Smartest_Man_In_The_World
Colonel Mustard 2316 P A_Game_Of_Clue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
