









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
OOP stands for Object-Oriented Programming. Procedural programming is about writing procedures or functions that perform operations on the data, while object-oriented programming is about creating objects that contain both data and functions.
Typology: Lab Reports
1 / 16
This page cannot be seen from the preview
Don't miss anything!










cout << "\t\t\t=> Default constructor for class SCHOLAR was called!" << endl; Number_of_Publications = 0; } //Parameterised Constructor SCHOLAR(int p) { cout << "\t\t\t=> Parameterised constructor for class SCHOLAR was called!" << endl; Number_of_Publications = p; } //Destructor ~SCHOLAR() { cout << "\t\t\t~SCHOLAR was called!" << endl; } //Getter and Setter Functions void set_NumberOfPublication(int P) { Number_of_Publications = P; } int get_NumberOfPublication() { return Number_of_Publications; } //Display Function void print() { cout << "Scholar's Name: " << getName() << endl; cout << "Scholar's Age: " << getAge() << endl; cout << "Scholar's Number of publications: " << Number_of_Publications << endl; } }; class AUTHOR : public SCHOLAR { public: //Data Members string A_name; int A_age; int Number_of_Books; //Default Constructor AUTHOR() { cout << "\t\t\t=> Default constructor for class AUTHOR was called!" << endl; A_name = ""; A_age = 0; Number_of_Books = 0; } //Parameterised Constructor AUTHOR(string n, int a, int p) :SCHOLAR(p)//Calling Parent's Class Parameterised constructor! { cout << "\t\t\t=> Parameterised constructor for class AUTHOR was called!" << endl; A_name = n; A_age = a; Number_of_Books = p; }
//Destructor ~AUTHOR() { cout << "\t\t\t~AUTHOR was called!" << endl; } //Getter and Setter Functions void setName(string N) { A_name = N; } void setAge(int A) { A_age = A; } void setBooks(int B) { Number_of_Books = B; } string getName() { return A_name; } int getAge() { return A_age; } //Display Function void print() { cout << "Author's Name: " << A_name << endl; cout << "Author's Age: " << A_age << endl; cout << "Author's Number of publications: " << Number_of_Publications << endl; cout << "Author's Number of Books: " << Number_of_Books << endl; } }; void main() { system("color B5"); cout << "\t\t
t------------------------------------------------------------------"; cout << "\n\t\t\t| |"; cout << "\n\t\t\t| TASK 1 |"; cout << "\n\t\t\t| |"; cout << "\n\t\t
t------------------------------------------------------------------\n\n"; AUTHOR A1("Azka Khan", 35, 5);//An object of class AUTHOR is instantiated cout << "________________________________________________________________________________ ________________________________________\n\n"; A1.TEACHER::setName("Azka Khan");//Overriding set function of class TEACHER was called! A1.TEACHER::setAge(35);//Overriding set function of class TEACHER was called!
#include
//Data Member to store Professional experience int p_experience; public: //Default Constructor TEACHER() { cout << "\t\t\t=> Default constructor for class TEACHER was called!" << endl; p_experience = 0; } //Parameterised Constructor TEACHER(int exp) { cout << "\t\t\t=> Parameterised constructor for class TEACHER was called!" << endl; p_experience = exp; } //Destructor Definition ~TEACHER() { cout << "\t\t\t~TEACHER was called!" << endl; } void setExperience(int P) { p_experience = P; } int getExperience() { return p_experience; } //Display Function void print() { cout << "Teacher's Name: " << getName() << endl; cout << "Teacher's Age: " << getAge() << endl; cout << "Professional Experience: " << getExperience() << endl; } }; class AUTHOR: public PERSON{ //Data Members int Number_of_Books; //Data Member to store Professional experience int p_experience; public: //Default Constructor AUTHOR() { cout << "\t\t\t=> Default constructor for class AUTHOR was called!" << endl; Number_of_Books = 0; p_experience = 0; } //Parameterised Constructor AUTHOR(int p,int exp) { cout << "\t\t\t=> Parameterised constructor for class AUTHOR was called!" << endl; Number_of_Books = p;
EXPLANATION:
setPrice(); setSales(); } void DisplayData() { cout << "\t\t
t------------------------------------------------------------------"; cout << "\n\t\t\t| |"; cout << "\n\t\t\t| Item's Description |"; cout << "\n\t\t\t| |"; cout << "\n\t\t
t------------------------------------------------------------------\n\n"; cout << "\t\t\t=> Item's Title: " << getName()<<endl; cout << "\t\t\t=> Item's Price: " << getPrice() <<" Rupees" << endl; cout << "\t\t\t=> Item's Sales for three Month: " << endl; for (int i = 0; i < 3; i++) { cout << "\t\t\t=> Month " << i + 1 << " : " << sales[i] << " Rupees" << endl; } cout << "\n\n"; } }; class HardwareItem : public Item { string manufacture; public: void setManufacture() { cout << "Enter the name of Item's Manufacture: "; cin.ignore(); getline(cin, manufacture); } string getManufacture() { return manufacture; } void getData() { setName(); setPrice(); setSales(); setManufacture(); } void DisplayData() { int* SALES = getSales(); cout << "\t\t
t------------------------------------------------------------------"; cout << "\n\t\t\t| |"; cout << "\n\t\t\t| Hardware Item |"; cout << "\n\t\t\t| |"; cout << "\n\t\t
t------------------------------------------------------------------\n\n";
cout << "\t\t\t=> Item's Title: " << getName()<<endl; cout << "\t\t\t=> Item's Price: " << getPrice()<<" Rupees"<<endl; cout << "\t\t\t=> Item's Manufacturer: " << getManufacture() << endl; cout << "\t\t\t=> Item's Sales for three Month: " << endl; for (int i = 0; i < 3; i++) { cout << "\t\t\t=> Month " << i + 1 << " : " << SALES[i] << " Rupees" << endl; } cout << "\n"; } }; class SoftwareItem : public Item { string OS_Name; public: void setOS_Name() { cout << "Enter Operating System's Name: "; cin.ignore(); getline(cin, OS_Name); } string getOS_Name() { return OS_Name; } void getData() { setName(); setPrice(); setSales(); setOS_Name(); cout << "\n"; } void DisplayData() { int* SALES = getSales(); cout << "\t\t
t------------------------------------------------------------------"; cout << "\n\t\t\t| |"; cout << "\n\t\t\t| Software Item |"; cout << "\n\t\t\t| |"; cout << "\n\t\t
t------------------------------------------------------------------\n\n"; cout << "\t\t\t=> Item's Title: " << getName() << endl; cout << "\t\t\t=> Item's Price: " << getPrice() << endl; cout << "\t\t\t=> Item's Operating System: " << getOS_Name() << endl; cout << "\t\t\t=> Item's Sales for three Month: " << endl; for (int i = 0; i < 3; i++) { cout << "\t\t\t=> Month " << i + 1 << " : " << SALES[i] << " Rupees" << endl; } }