0% found this document useful (0 votes)
2 views

CS1004 C++ ObjectOrientedProgramming Midterm 2 v3 Moderated

This document outlines the Sessional-II Exam for Object Oriented Programming (CS1004) at the National University of Computer and Emerging Sciences, Karachi Campus. It includes details about the exam structure, questions related to object-oriented concepts, and programming tasks involving class design and functionality for a security management system and a pastry shop. The exam is designed to assess students' understanding of OOP principles and their ability to implement them in C++.

Uploaded by

qaimlakho1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

CS1004 C++ ObjectOrientedProgramming Midterm 2 v3 Moderated

This document outlines the Sessional-II Exam for Object Oriented Programming (CS1004) at the National University of Computer and Emerging Sciences, Karachi Campus. It includes details about the exam structure, questions related to object-oriented concepts, and programming tasks involving class design and functionality for a security management system and a pastry shop. The exam is designed to assess students' understanding of OOP principles and their ability to implement them in C++.

Uploaded by

qaimlakho1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

National University of Computer and Emerging Sciences

Karachi Campus

Object Oriented Sessional-II Exam


Programming (CS1004) Total Time (Hrs): 1
Total Marks: 30
Date: April 6th 2024
Total Questions: 03
Course Instructor(s)
Mr. Basit, Mr. Minhal, Ms.Sumaiya, Ms.Sobia, Ms.Abeeha,
Ms.Bakhtawer, Ms.Abeer, Ms.Atiya, Ms.Rafia

___________ __________ _____________________


Roll No Section Student Signature

Do not write below this line


Attempt all the questions.

CLO #1: Discuss knowledge of underlying concepts of object-oriented paradigm like abstraction,
encapsulation, polymorphism, inheritance etc.
Q1: Write short answers (2-3 lines) for the following questions: [15 minutes, 10 marks(5*2)]
a. Do you agree with the statement: “When a function is declared a friend by a class, it becomes
a member of that class”? Justify your answer.
b. Can a constant member function be overloaded with a non-constant version?
c. Can the diamond problem be mitigated explicitly disambiguating member function calls in the
derived class?
d. What will be the order of constructors and destructors in a code snippet given below:
class A { };
class B { };
class C : public B, public A { };
class D : public C { };
main() { D d1; }
e. Is there any problem in a code snippet given below? If yes, how can we resolve it?
class A { public: int x;};
class B : private A { };
class C : public B { public: C() {x = 10; } };
main() { C c1;}

CLO #4: Design and assess small and medium scale C++ programs using OOP principles.
Q2: You are developing a software system to manage various security professionals and their roles
within a firm. The system has a class hierarchy to represent different roles and entities involved in
the industry. [20 minutes, 10 marks (4*2.5)]
a. Create an Employee class that has basic information about individuals employed such as their
name, employee ID, salary all of which are protected members. Create a parameterized
constructor to set these attributes.
b. Create an Analyst class that represents security analysts and inherits from the Employee
class. It has additional attributes “specialization” and “isCertified”. Create a parameterized
constructor to set the attributes. The specialization can only be “Network”, “Incident

Spring 2024 Department of Computer Science Page 1 of 2


National University of Computer and Emerging Sciences
Karachi Campus

Response”, or “Threat Intelligence”. The class has a function HasCertifications ( ). If the


analyst has one certification then display that certification and if the analyst has more than
one certification then display the list of certifications or else display “Not Certified”.
c. Create an Engineer class that represents security engineers and also inherits from the
Employee class. It has additional attributes isExpert, isAssigned (initially set to false), and a
list of projects which is dynamically allocated. Each security engineer works on atleast 1
project. Create a parameterized constructor to set the attributes. The class has functions
AddProjects( ) and AssignProject( ).
➢ AssignProject( ) – The engineer is assigned a project if he/she is an expert. If the
engineer is an expert set isAssigned to “True” or else set it to “False”.
➢ AddProjects( ) – If the engineer is assigned a project add the project to the list of
projects or else display no projects to add.
d. Create a class for Lead Professional who excels in both security analysis and engineering.
Implement a functionality that shows the projects and certifications for the lead professional.

CLO #4: Design and assess small and medium scale C++ programs using OOP principles.
Q3: You are required to develop a Software for a pastry shop located in UAE. The system should
assist in managing the pricing, taxes, and profits from pastry sales. Each pastry has a production
cost, and the price at which it is sold by the shop is subject to certain taxes and pricing regulations.
Additionally, there is a requirement to calculate the retail price for each pastry, considering a 6%
Goods and Services Tax (GST). [25 minutes, 10 marks (5*2)]

Below are the detailed regulations:


• All pastries are subject to a 10% production cost markup to cover labor and other expenses.
• Sweet pastries are subject to an 8% sales tax, whereas savory pastries are subject to a 5%
sales tax.
• After calculating taxes, the shop retains 70% of the retail profit from the total cost per pastry.

Tasks: The system should accommodate the following functionalities:


a. Pastry Classes: Implement two classes, SweetPastry and SavoryPastry, derived from a base
class Pastry. Each class should store information about the pastry name, ingredients,
production cost, and tax rates specific to each type of pastry.
b. Polymorphism: Utilize function overriding for the function(s) defined in the Pastry base class
to calculate total cost, retail price, and profit for each type of pastry.
c. Friend Function: Implement a friend function named PastryCalculator to perform specific
calculations related to pastries. This function should calculate the total cost of a pastry,
including taxes.
d. Friend Class: Implement a friend class named PastryReport to generate a report of the total
sales and profits for the pastry shop.
e. PastryShop Class: Implement a class named PastryShop to manage multiple pastries. This
class should allow adding pastries and calculating the total profit from all sales.

------------- The End -------------

Spring 2024 Department of Computer Science Page 2 of 2

You might also like