Question: QUESTION 3. This is a compulsory question related to OOP. You are required to provide a mix of descriptive and C++ code answers The class


QUESTION 3. This is a compulsory question related to OOP. You are required to provide a mix of descriptive and C++ code answers The class diagram shown in Figure 1 illustrates a snippet of a software solution that is used by a stock management system of an electronics shop. Answer the following questions in the context of the C++ programming language: a) What is encapsulation? In your answer, refer to Figure 1, and make sure to list and explain the different types of access modifiers used. (8 marks) b) What are inheritance and polymorphism? In your answer, refer to Figure 1 . ( 8 marks) c) Consider the following array declaration: Component * components [3]; Write the required code to instantiate the FIRST element of the array as an object of type Capacitor and the TWO other array elements as instances of class LogicGate. (7 marks) d) Write the implementation of the function displayDetails() for the scenario at the start of this question. [HINT: you must write THREE functions in all- one for each class]. (9 marks) e) Write the implementation of the function enterDetails() for the scenario at the start of this question. [HINT: you must write THREE functions in all - one for each class]. (9 marks) f) What is the name of the technique used for the implementation of the functions mentioned in questions 3(d) and 3(e) ? (2 marks) Page 3 of 4 g) Write the required code asking a user to enter the required details for every instance element of array components. Make sure to invoke and use the appropriate function(s). ( 6 marks) h) Write the code required to display all the details of the components stored in the array components. (6 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
