C++ solve
SECTION C: STRUCTURED QUESTIONS [45 Marks! Instruction: This section consists of THREE (3) questions The marks are as indicated in the question. Write your answers on papers. Question 1 Consider the two classes, Student and Lecturer defined in Program C-1. // Program C-1 #include
4 using namespace std; 5 6 class Student 7 private: 8 string name; 9 string matric; 10 string programi 12 string email; 12 string phone; 13 public: 14 Student Istring n, string me string p, stringe, string ph) 15 name = 1; 16 matric-mi 17 program - P: 18 email - 19 phone - ph; 20 21 22 23 string getName() const {return name: void setName(string value) name = value; } 24 25 string getMatrict) const {return matric: 26 void set Matric(string value] [ matric = value; } 27 28 29 string get Program() const {return program:) 30 void set Programstring value) program = value; } 31 32 string get Email() const return email, 33 void setEmail(string value) 1 email = value;) 34 35 string get Phone () const return email: 36 void setPhone (string value) phone - value; 37): 38 39 40 class Lecturer 41 private: 42 string name; 43 string staffid; 44 string faculty: 45 string email; 46 string phone: 47 48 public: 49 Lecturer istring r, string id, string , 50 stringe, string ph) 52 name - n; 52 startId = id; 53 faculty - 1: 54 email - 55 phone - ph; 56 57 58 string getName() const {return name: 59 void setName(string value) { name = value; } 60 61 string getStaffId() const {return staffid;) 62 void set StaffId(string value) { staffId - value; 63 64 string get Faculty() const {return faculty;) 65 void set Faculty string value) faculty - value; } 66 67 68 string get Email() const { return email: 69 void setEmail string value) email = value: 70 71 string get Phone() const {return email: 72 void setPhone latring value) 1 phone - value; 73) a. Identify and justify ONE (1) issue about the implementation of the classes in the program (5 marks) b. Provide two solutions to fix the issue in (a) using two different approaches below. Give your answers by rewriting the original code. You may add additional classes whenever necessary 1. i using composition ii. using composition and inheritance (10 marks) Question 2 16 Consider several classes declared in Program C-2. // Program C-2 3 #include 4 using namespace std; 5 6 class Person 7. 7 string name; 81 9 10 class Teacher; // foward declaration 11 12 class Student : public Person! 13 string matric; 14 Teacher teacher: 15; 16 17 class Office 18 string department; Question 2 Consider several classes declared in Program C-2. 17 Program C-2 tinelude 4 using namespace std; 6 class Person string name; B: 9 10 class Teacher; // foward declaration 11 12 class Student : public Person 13 string matric; 14 Teacher teacher 15 16 17 class Offion 19 string department, 19 20 21 class statt public Person 22 string staffid: 23 Office office; 24 25 96 clasa Teacher: public stati 27 string expertise: 28 Student studenti 297 a. Based on the program, determine what type of relationship do the following classes form? Note: Write No Relationship if they do not form any relationship to each other 1. Teacher and Student ii. Student and office iii. Staff and Office Iv. Teacher and person (4 marks) b. Draw the UML class diagram for the program which includes all the classes and relationships between them. (11 marks) Question 3 a. Explain the concept of polymorphism and dynamic binding. How do they relate to each other? (6 marks) b. Consider Program C-3. 1 // Program C-3 3 Hinclude "; 15 16 cin>> choice 17 cout 2) throw 5000; 21 22 23 return choice; 24 1 25 26 int main 27 try 28 int choice - menu(); 29 30 if (choice - 111 31 cout