0% found this document useful (0 votes)
36 views2 pages

Assignment No.6 (Composition)

1. The document provides details for two programming assignments on object-oriented concepts. It describes 6 classes for the first assignment involving inheritance, aggregation, and composition relationships between classes like University, Department, and Professor. 2. The second assignment involves 4 classes - Processor, MainMemory, MotherBoard, and Computer - to model components of a computer system using aggregation and composition. 3. Students are instructed to draw UML diagrams for each assignment, implement the classes as specified, create objects in main(), and call relevant methods by the deadline of June 12, 2023. Late or copied submissions will not receive marks.
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)
36 views2 pages

Assignment No.6 (Composition)

1. The document provides details for two programming assignments on object-oriented concepts. It describes 6 classes for the first assignment involving inheritance, aggregation, and composition relationships between classes like University, Department, and Professor. 2. The second assignment involves 4 classes - Processor, MainMemory, MotherBoard, and Computer - to model components of a computer system using aggregation and composition. 3. Students are instructed to draw UML diagrams for each assignment, implement the classes as specified, create objects in main(), and call relevant methods by the deadline of June 12, 2023. Late or copied submissions will not receive marks.
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

Object Oriented Programming

Assignment #6
Due Date: Before Coming Class (6-12-2023, 9:30 am)
Instructor: Dr. Javid (1-01-2023)
Note: The deadline is hard, late submission and copied solutions will
credit zero marks. The Demos of this assignment will be conducted in the
lab class. (Comment your program properly, write down your Name,
Registration No. at the top of .cpp file in comments. Take care of indentation
when writing program.).

Task-1
Consider six classes i.e. Person, Professor, Researcher, Department, Laboratory, and University
having following specifications.

Class University has


• Two attributes of type string i.e. universityName and location
• An attribute named dept of type Department

Class Department has


• Two attributes i.e. deptID, deptName
• A two-argument constructor to initialize data fields with user-defined values
• A member function display() to show all attribute values

Class Laboratory contains


• Two attributes i.e. labID and experimentNo
• A two-argument constructor to initialize data member with user-defined values

Class Person has


• Two attributes i.e. name and age
• A parameterized constructor to initialize attributes with user-defined values
• A member function display() to show its attribute values

Class Professor is derived from class Person and has


• A data field named subectName of type string
• A data field named dept of type Department
• A two-argument constructor to initialize both attributes of user-defined values

Class Researcher is derived from class Professor and has


• An additional attribute named lab of type Laboratory
• A constructor to initialize lab with user-defined value
a) Draw UML diagram for each class and show inheritance, aggregation, and composition
relationship between these classes.
b) Implement all these classes while illustrating the concept of aggregation and composition
in terms of ownership and life-cycle. Also create objects in the main() and call the
corresponding functions.

Task-2
A class named Processor has
• Two attributes i.e. processName and price
• A parameterized constructor to initialize attributes with user-defined values
Class MainMemory consists of
• Two attributes i.e. size and price
• A parameterized constructor to initialize attributes with user-defined values
Class MotherBoard has
• a data member named compName of type string
• a no-argument constructor to initialize with default name intel
Design a class named Computer that includes
• A data member named proc of type Processor
• A data member named ram of type MainMemory
• A data member named mboard of type MotherBoard
• A parameterized constructor that accept two arguments of type Processor and MainMemory to
initialize members of these types. Moreover, within this constructor, instantiate object of
MotherBoard to initialize mboard data field.
a) Write a main() and create necessary objects of the classes.
b) Draw UML diagram for each class and show inheritance, aggregation, and/or
composition relationship between these classes.

You might also like