Question: 2. The problem given above involves several OOP concepts including inheritance and polymorphism. a. Explain TWO (2) main roles of the inheritance concept in the






2. The problem given above involves several OOP concepts including inheritance and polymorphism. a. Explain TWO (2) main roles of the inheritance concept in the above problem. Indicate in which part of the class diagram these roles take place. (16 marks) b. Explain how the concept of polymorphism plays its role in the above problem. (10 marks) c. Identify TWO (2) methods that will be specified as polymorphic. Justify your answer. Finaly, explain how you are going to make these methods polymorphic. (12 marks) Question [100 Marks A school is currently running a mentoring programme for its students. The students are divided into two groups, mentors and mentees. Mentors are more knowledgeable students and offer helps to mentees. They are chosen from those students with good CPAs. The programme offers two types of mentoring: Coaching-based mentoring: mentors will coach their mentees in particular areas, e.g., "C# programming", "Game Programming", etc. Therefore, a mentor must be expert in that area. Support-based mentoring: mentors offer their supports to the mentees without having to meet face to face. Thus, the mentor need to provide their phone numbers. Further, each mentee is assigned with only one mentor. Mentee's progress are kept track based on their levels, i.e. from level 1 to 5 where 5 indicates a mastery level. Given a class diagram that models the above problem in Figure 1 and the details about the class diagram in Table 2. Answer the questions 1 to 3 below. Note: As for questions 1 and 2, write your answers on papers, and for question 3, write your program using any CHIDE such as DevCpp. Use the codebase program provided, main.cpp. 1. Determine whether the following classes form any relationship to cach other in the context of Object-Oriented Programming (OOP). If so, name the type of relationship, otherwise write No Relationship. a. Coach and Support b. Mentee and Student c. Mentee and Mentor d. Coach and Mentor e. Coach and Student f. Coach and Mentee (12 marks) Mentoring Type Coach-based Table 1: Sample data Mentee's name Mentee's Mentor Level Abdul Samad 2 Ahmad Kamal CPA: 3.87 Expertise. Web Programming Siti Nurdiana 1 -Not assigned yet- Jazlan Kamal 1 Siti Aminah CPA: 3.98 Phone : 013-89001000 Omar Abdullah 2 Ahmad Kamal CPA: 3.87 Expertise: Web Programming Support-based Coach-based 5. Using a loop, print the list of mentees you created in 3(t). The output should look like as in Figure 2. (2 marks) h. Remove or unassign the mentor from the last mentee. (1 mark) i. Using a loop, print the updated list of mentees and their mentors. Print only the names. See Figure 2 for the expected output. (3 marks) Abbreviations: Student name name 1 level mentor c: expertise P: phone Student(n) getName() setName) printo Mentee Mentor level Mentorn. c) printo Mentee(nl) assignMentorm) removeMentoro getMentorName() print) Coach Support expertise phone Support(n.cp) Coach(n.c. e) print() print() Figure 1: Class diagram Table 2: Description of the members of each class. Class Members Description class Student name Student's name Student) A constructor getName() and Accessor and mutator to the attribute setName() print) prints the student's information class Mentea level The class attribute indicating the level of progress for each mentee. There are five levels, from 1 to 5, where levels indicates mastery level Menteet) assignMentor) removeMentor) getMentorName() A constructor assigns a mentor to mente unassigns or removes the mentor from a mentee. returns the mentor's name of the mentee. However, if the mentee has not been assigned with any mentor, this method will return an empty string prints the mentee's information including: name and level. mentor's details depending the type of the mentor, i.e. either a coach mentor or a support mentor. However, if the mentee has not been assigned with any mentor, a message "No mentor yet will be printed instead print Men's class Mentor cpa Mentor) printo A constructor prints the mentor's information class Coach expertise The mentor's area of expertise that he or she can be coaching, e.g. "C++ Programming", "Game Programming", cte. Coach A constructor print prints the coach-based mentor's information including name, cpa and expertise class Support phone Support() print The mentor's phone number. A constructor prints the support-based mentor's information including name, pa and phone Initial list of students along with their mentor Mantea's Name : Abdul Samad Mante's Level : 2 Mentoring type Conch-based Amadeal Mentor's CP Mentor's Experti Web Programming Mantea's Name : Siti Nurdiana Mente's Level II - Nomor yet ** Output of question 3g) Mantea's Name : Jazlan Kamal Mente's Level: Mentoring type: Support-based Mentor's Name : Siti lainah Mentor's CPA 3.05 Mentor's Phone 013-39001000 Mantea's Name : Onse Abdullah Ment's eve 2 Mentoring type: Coach-based Mentor's Name : Ahmad Kamal Mentor's CPA Mentor's Expertise: Web Programming Updated list Mente Abdul Samad Siti Nordians Jazlan Rama C Abdallah Ahmad Kamal Output of question 3() Biti minh Figure 2: Program output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
