Professional Documents
Culture Documents
Lab Report 9
Lab Report 9
Lab # 09 OOP
Names
FA21-BEE-128
Registration
Numbers
Class 3A (BEE)
Lab Assessment
Post Lab Total
Pre-Lab In-Lab
Data Presentation Data Analysis Writing Style
LAB 09 – Composition / Containership
https://onlinegdb.com/z5xRUEMXM
Task 4.1 Example
In this example we will talk about composition. Composition is about expressing
relationships between objects. In this object has “has a” relationship with class and it is
very useful in the given example we will see demonstration of composition in a program.
LINK:
https://onlinegdb.com/nloIR2Icc
Task 5.1
In this task we have to code the example 4.1 with mentioning some message
indicating the class construction and destruction in the constructors and
destructors of each class.
studentRecord();
~studentRecord();
LINK:
https://onlinegdb.com/iaxNpkthN
Task 5.2
In this task we created an Address class, which contains street#, house#, city and
code. We created another class Person that contains an address of type Address.
We gave appropriate get and set functions for both classes, like
Address getAddress()
{
return addr;
}
LINK:
https://onlinegdb.com/XU0vuJ7m7
Task 5.3
In this program we just created a program, which has two classes one is Date
having members (day, month, year) and the other class is called Employee. The
employee has Date class as member as each employee has Date of joining, Date of
Birth etc. I determined if an employee joined the organization within last five years
if the current year is 2*** by using
“if(currentYear - emps[i].getDoJYear() <= 5)”
And I determined if an Employee has age less than 40 years by using
“if(currentYear - emps[i].getDoBYear() <= 40)”
LINK:
https://onlinegdb.com/ejQhQ6Hu-C
Task 6.1
In this program we have to just read digits as Characters input and convert to
equivalent numeral values we did it by converting character to integer using this
int asci::ascii(char a)
{
return int(a);
}
Taking in character and returning it as integer.
LINK:
https://onlinegdb.com/aM2lzFGME