Professional Documents
Culture Documents
Muhammad Mamoon Irfan - F2023266192 - OOPLAB - V-6 - LAB#4
Muhammad Mamoon Irfan - F2023266192 - OOPLAB - V-6 - LAB#4
Muhammad Mamoon Irfan - F2023266192 - OOPLAB - V-6 - LAB#4
Email: f2023266192@umt.edu.pk
Assignment No: 4
Announcement date:3/31/2024
Section: V6
Object Oriented Programming (OOP)
Source Code:
#include <iostream>
using namespace std;
class Bus
{
private:
string bus_Number, owner_Name;
int P_Capacity;
public:
string bus_number, owner_name;
int P_capacity;
Bus()
{
bus_Number = "0000";
owner_Name = "Muhammad";
P_Capacity = 0;
}
Bus(string bus_number, string owner_name, int P_capacity)
{
bus_Number = bus_number;
owner_Name = owner_name;
P_Capacity = P_capacity;
}
void setbus_Number(string bus_number)
{
bus_Number = bus_number;
}
string getbus_Number()
{
return bus_Number;
}
void setowner_Name(string owner_name)
1
Object Oriented Programming (OOP)
{
owner_Name = owner_name;
}
string getowner_Name()
{
return owner_Name;
}
void setP_capacity(int P_capacity)
{
P_Capacity = P_capacity;
}
int getP_capacity()
{
return P_Capacity;
}
void getBus()
{
cout << "Enter Bus Number Plate:" << endl;
cin >> bus_number;
cout << "Enter Owner Name:" << endl;
cin >> owner_name;
cout << "Enter Passangers Capacity:" << endl;
cin >> P_capacity;
}
void setBus()
{
bus_Number = bus_number;
owner_Name = owner_name;
P_Capacity = P_capacity;
}
void putBus_display()
{
cout << "The bus license platenumber is:" << bus_Number << endl;
cout << "The owner name of the bus is:" << owner_Name << endl;
cout << "The bus passenger capacity is:" << P_Capacity << endl;
}
int Book()
{
return P_Capacity++;
}
int Cancel()
{
2
Object Oriented Programming (OOP)
return P_Capacity--;
}
void putbus_display()
{
cout << bus_Number << "\t";
cout << owner_Name << "\t";
cout << P_Capacity << endl;
}
};
int main()
{
// Here we test default constructor:
Bus passval;
passval.putBus_display();
3
Object Oriented Programming (OOP)
passnewval.setP_capacity(80);
passnewval.putbus_display();
passnewval.setbus_Number("FSD 5467");
passnewval.setowner_Name("Rehber Express");
passnewval.setP_capacity(60);
passnewval.putbus_display();
passnewval.setbus_Number("ISD 4567");
passnewval.setowner_Name("Skyways");
passnewval.setP_capacity(55);
passnewval.putbus_display();
}
Object Code:
4
Object Oriented Programming (OOP)
Task: 2
Source Code:
#include <iostream>
using namespace std;
class Faculty
{
private:
int Fac_Id;
string F_Name, L_Name, F_qualification;
float Salary;
public:
int F_Id;
string F_name, L_name, F_Qualification;
float salary;
Faculty()
{
Fac_Id = 0;
F_Name = "Asif";
L_Name = "Irfan";
F_qualification = "Bscs";
Salary = 20000.00;
}
Faculty(int F_Id, string F_name, string L_name, string
F_Qualification, float salary)
{
if (F_Id >= 1001 && F_Id <= 1065)
{
Fac_Id = F_Id;
}
F_Name = F_name;
L_Name = L_name;
F_qualification = F_Qualification;
if (salary >= 20000.00 && F_Id <= 100000.00)
{
Salary = salary;
}
}
void setF_Id(int F_Id)
{
5
Object Oriented Programming (OOP)
Salary = salary;
}
}
float getsalary()
{
6
Object Oriented Programming (OOP)
return Salary;
}
void read()
{
cout << "Enter Faculty Id:" << endl;
cin >> F_Id;
cout << "Enter First Name:" << endl;
cin >> F_name;
cout << "Enter Last Name:" << endl;
cin >> L_name;
cout << "Enter Qualifiacation:" << endl;
cin >> F_Qualification;
cout << "Enter Your Salary:" << endl;
cin >> salary;
}
void setmethod()
{
if (F_Id >= 1001 && F_Id <= 1065)
{
Fac_Id = F_Id;
}
F_Name = F_name;
L_Name = L_name;
F_qualification = F_Qualification;
if (salary >= 20000.00 && F_Id <= 100000.00)
{
Salary = salary;
}
}
void write_display()
{
cout << "The faculty identification number is:" << Fac_Id <<
endl;
cout << "The faculty First Name is:" << F_Name << endl;
cout << "The faculty Last Name is:" << L_Name << endl;
cout << "The faculty Qualification is:" << F_qualification <<
endl;
cout << "Salary is:" << Salary << endl;
}
bool post_graduate(string F_qualification)
{
if (F_qualification == "MS" || F_qualification == "PHD")
7
Object Oriented Programming (OOP)
{
return true;
}
else
{
return false;
}
}
float Get_Take_Home_Salary(float Salary)
{
if (Salary >= 20000.00)
{
float tax = (7 / 100) * Salary;
Salary -= tax;
return Salary;
}
else
{
return -1;
}
}
bool Is_joined(float Salary)
{
if (Salary >= 20000.00)
{
return true;
}
else
{
return false;
}
}
};
int main()
{
// Here we test default constructor:
Faculty passval;
passval.write_display();
8
Object Oriented Programming (OOP)
Object Code:
9
Object Oriented Programming (OOP)
10