Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Object Oriented Programming

Assignment #5
Due Date: Saturday December 30, 2023 9:00 am
Instructor: Dr. Javid (23-12-2023)
Note: The deadline is hard, late submission and copied solutions will
credit zero marks. The Demos of this assignment will be conducted on 30th
December, 2023 in the Lab class. (Comment your program properly, write
down your Name, Registration No. at the top of .cpp file as comment. Take
care of indentation when writing program.).

Task-I
Consider an abstract class named Computer having two fields/attributes (i.e.
companyName, price) and a single function named show(). Create a class named
Desktop that inherits Computer class and adds fields representing color, monitor size,
and processor type and this class overrides function named show() to display values of its
all attributes. A class named Laptop is inherited from Computer class and adds fields:
color, size, weight, and processor type and it also override function named show() to
display values of its all attributes
All the classes should have parameterized constructors to assign values to the
attributes/fields. Write a main() function that instantiates objects of derived classes to
access respective show() function using pointer to Computer class (dynamic binding).
Also draw UML diagram of the classes mentioned above.

Task-2
Create a class named Person, which contains: A pure virtual function named print() and
Two data fields i.e. personName and age. Second class named named Patient that
inherits Person class, and contains:Two data fields i.e. diseaseType and
recommendedMedicine. The print() function is overridden to display all details relevant
to a patient. In the main() function, create instance of derived class to access respective
print() function using dynamic binding.

You might also like