0% found this document useful (0 votes)
43 views13 pages

Lab Report 09 Oop

1) The document describes three lab tasks and one home task completed by the student Muhammad Haris involving object-oriented programming concepts like classes, composition, and inheritance. 2) In lab task 1, classes were created for student, employee, and manager records and data was input using composition. 3) Lab task 2 involved creating classes for address and person with address data input using composition. 4) Lab task 3 focused on creating classes for date and employee and using inheritance for date of birth and joining. 5) The home task involved creating classes for characters and integer and converting a character to its integer value using composition.

Uploaded by

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

Lab Report 09 Oop

1) The document describes three lab tasks and one home task completed by the student Muhammad Haris involving object-oriented programming concepts like classes, composition, and inheritance. 2) In lab task 1, classes were created for student, employee, and manager records and data was input using composition. 3) Lab task 2 involved creating classes for address and person with address data input using composition. 4) Lab task 3 focused on creating classes for date and employee and using inheritance for date of birth and joining. 5) The home task involved creating classes for characters and integer and converting a character to its integer value using composition.

Uploaded by

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

LAB REPORT 09

NAME:- MUHAMMAD HARIS

ROLL NO:- FA20-BEE-237

CLASS:- BEE-3C

COURSE:- OOP
LAB TASK 01
#include<iostream>

#include<string>

using namespace std;

class studentRecord

private:

string degree;

public:

studentRecord()

cout<<"object of studentRecord is constructed"<<endl;

~studentRecord()

cout<<"object of studentRecord is destructed"<<endl;

void getdata()

cout<<"Enter Degree: ";

cin>>degree;

};

class employeeRecord
{

private:

int emp_id;

double salary;

public:

employeeRecord ()

cout<<"object of employeeRecord is constructed"<<endl;

~employeeRecord ()

cout<<"object of employeeRecord is destructed"<<endl;

void getdata()

cout<<"\nEnter Employee ID: ";

cin>>emp_id;

cout<<"Enter Salary: ";

cin>>salary;

};

class manager

private:
string title;

double dues;

employeeRecord emp;

studentRecord stu;

public:

manager()

cout<<"Object of manager class is constructed"<<endl;

~manager()

cout<<"Object of manager class is destructed"<<endl;

void getdata()

emp.getdata();

cout<<"Enter Title: ";

cin>>title;

cout<<"Enter Dues: ";

cin>>dues;

stu.getdata();

};

int main()
{

manager m1;

cout<<"Enter data for manager 1: ";

m1.getdata();

return 0;

LAB TASK 02
#include<iostream>

#include<string>

using namespace std;

class Address

private:
int street;

int house;

char city[20];

int code;

public:

Address():street(),house(){}

void getdata()

cout<<"enter the street no : "<<endl;

cin>>street;

cout<<"enter the house no : "<<endl;

cin>>house;

cout<<"enter the city : "<<endl;

cin>>city;

cout<<"enter the code : "<<endl;

cin>>code;

void showdata()

cout<<"street no# "<<street<<endl;

cout<<"house no# "<<house<<endl;

cout<<"city :"<<city<<endl;

cout<<"code :"<<code<<endl;

}
};

class person

private:

Address add;

public:

void getdata()

add.getdata();

void showdata()

add.showdata();

};

int main()

person P;

P.getdata();

P.showdata();

return 0;

}
LAB TASK 03
#include<iostream>

#include<string.h>

using namespace std;

class Date

public:

int day,month,year;

void getdata()

cout<<"ENTER THE YEAR:";


cin>>year;

cout<<"ENTER THE MONTH:";

cin>>month;

cout<<"ENTER THE DAY:";

cin>>day;

};

class Employee

public:

Date Doj,Dob;

void getdata()

cout<<"ENTER THE DATE OF JOINING:\n";

Doj.getdata();

cout<<"ENTER THE DATE OF BIRTH:\n";

Dob.getdata();

void display1()

if(Doj.year>=2007)

{
cout<<"\nDATE OF JOINING IS:\n";

cout<<"YEAR:"<<Doj.year<<"\nMONTH:"<<Doj.month<<"\nDAY:"<<Doj.day<<endl;

else

cout<<"YOUR DATE OF JOINING IS MORE THAN 5 YEARS";

void display2()

if(2012-Dob.year<=40)

cout<<"\nDATE OF BIRTH IS:\n";

cout<<"YEAR:"<<Dob.year<<"\nMONTH:"<<Dob.month<<"\nDAY:"<<Dob.day<<endl;

else

cout<<"YOUR AGE IS MORE THAN 40 YEARS";

};

int main()

{
Employee e1;

e1.getdata();

e1.display1();

e1.display2();

return 0;

HOME TASK 1
#include <iostream>

#include <conio.h>

#include <string>

using namespace std;

class characters

public:
int b;

char a='b';

void getdata()

cout<<"Enter any character "<<endl;

cin>>a;

};

class integer

public:

int numeral;

characters c1;

void convert()

c1.getdata();

numeral=c1.a;

void sett()

{
cout<<"Numeral value is "<<numeral<<endl;

};

int main()

integer i1;

i1.convert();

i1.sett();

return 0;

CONCLUSION
In this lab I learnt about the concept of composition. I came to know how to use composition in
a class. Moreover, I am able to use composition in different real time scenarios also the
purpose of composition.

You might also like