Muhammad Mamoon Irfan - F2023266192 - OOPLAB - V-6 - LAB#4

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Object Oriented Programming (OOP)

Submitted To: Riaz Ahmed

SCHOOL OF SYSTEM AND


TECNOLOGY (SST) UNIVERSITY
3/31/2024 OF MANAGEMENT AND
TECNOLOGY

Department: Computer Science (SST/CS)

Email: f2023266192@umt.edu.pk

Submitted By: Muhammad Mamoon Irfan

Student ID: F2023266192 BS(CS)

Assignment No: 4

Announcement date:3/31/2024

Subject: Object Oriented Programming


(OOP)

Section: V6
Object Oriented Programming (OOP)

Object Oriented Programming (OOP)


Lab Assignment No 4
Task: 1
Important Note: My entire program was written by me. For this assignment, I used Visual
Studio. The source code is editable, not the screenshot.

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();

// Here we test parameterized constructor:


Bus passnewval("2345", "Ali", 30);
passnewval.putBus_display();

// Here we test Getter and Setter:


passnewval.setbus_Number("1234");
passnewval.setowner_Name("Wasif");
passnewval.setP_capacity(25);
passnewval.putBus_display();
// Here we test read and set methods:
passnewval.getBus();
passnewval.setBus();
passnewval.putBus_display();
// Here we test Book and cancel methods:
passnewval.Book();
passnewval.Cancel();
passnewval.putBus_display();
// Here we test Book and cancel methods:
passnewval.setbus_Number("LHR 3216");
passnewval.setowner_Name("Daewoo");
passnewval.setP_capacity(40);
passnewval.putbus_display();
passnewval.setbus_Number("KHI 3317");
passnewval.setowner_Name("Bilal Travels");
passnewval.setP_capacity(45);
passnewval.putbus_display();
passnewval.setbus_Number("KPK 9876");
passnewval.setowner_Name("Niazi Express");

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)

if (F_Id >= 1001 && F_Id <= 1065)


{
Fac_Id = F_Id;
}
}
int getF_Id()
{
return Fac_Id;
}
void setF_name(string F_name)
{
F_Name = F_name;
}
string getF_name()
{
return F_Name;
}
void setL_name(string L_name)
{
L_Name = L_name;
}
string getL_name()
{
return L_Name;
}
void setF_Qualification(string F_Qualification)
{
F_qualification = F_Qualification;
}
string getF_Qualification()
{
return F_qualification;
}
void setsalary(float salary)
{
if (salary >= 20000.00 && F_Id <= 100000.00)
{

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();

// Here we test parameterized constructor:


Faculty passnewval(1010, "Mamoon", "Irfan", "MS", 20000.00);
passnewval.write_display();

8
Object Oriented Programming (OOP)

// Here we test Getter Setter:


passnewval.setF_Id(1016);
passnewval.setF_name("Riaz");
passnewval.setL_name("Ahmed");
passnewval.setF_Qualification("PHD");
passnewval.setsalary(250000.00);
passnewval.write_display();
// Here we test read set methods:
passnewval.read();
passnewval.setmethod();
passnewval.write_display();
// Here we post_graduate, Get_Take_Home_Salary, Is_joined methods:
passnewval.post_graduate("BSCS");
passnewval.Get_Take_Home_Salary(100000.00);
passnewval.Is_joined(100000.00);
passnewval.write_display();
}

Object Code:

9
Object Oriented Programming (OOP)

10

You might also like