0% found this document useful (0 votes)
33 views

Lab 6

oop
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)
33 views

Lab 6

oop
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/ 7

OBJECT ORIENTED PROGRAMMING

OBJECTIVE:
 ALL OOP LAB TASKS

SUBMITTED BY:
MUHAMMAD NAWAZ(180443)

SUBMITTED TO:
ENGR.FAISAL NAWAZ

--------------------------------------------------------------------------------------------
LAB 6

Task 1:

SOURCE CODE:

#include<iostream>
using namespace std;
class Account
{
private:
double amount;
double accountNo;
int pin;
public:
Account():amount(0),pin(123456){}
Account(double Am,double An);
double setCredit(double Amm);
double getDebit(double Ammm);
void checkBalance();
};

class creditCard:public Account


{
public:
void checkBalance();
};

class checkingAccount:public Account


{
public:
void checkbalance();
};
Account::Account(double Am,double An)
{

amount=Am;
//cout<<amount<<endl;
accountNo=An;
//cout<<accountNo;
}
double Account::setCredit(double Amm)
{
//double a;
//Amm=a;
if(Amm>0)
{
amount =amount +Amm;
cout<<"your New balance is: "<<amount<<endl;
}else
{
cout<<"Error"<<endl;
}
}
double Account::getDebit(double Ammm)
{
double b=Ammm;
if(b>amount)
{
cout<<"Error";
}else
{
amount=amount-b;
cout<<"your remaing balance is: "<<amount<<endl;
}
}
void Account::checkBalance()
{
int EnPin;
cout<<"Enter your pin"<<endl;
cin>>EnPin;
if(EnPin==pin){
cout<<"your balance is: "<<amount;
}
else
cout<<"Error"<<endl;
}

int main()
{
Account A1(0,123456);
checkingAccount CA;
int choice;
cout<<"Enter your choice: "<<endl;
cout<<"1.Credit"<<endl;
cout<<"2.Debit"<<endl;
cout<<"3.check balance"<<endl;
cin>>choice;
switch (choice)
{
case 1:
A1.setCredit(900);
break;
case 2:
A1.getDebit(400);
break;
case 3:
CA.checkBalance();
break;
}
return 0;
}

OUTPUT:

TASK 2:

Source Code:
#include <iostream>
using namespace std;

class Mammals {
public:
void output() {
cout << "I am mammal" << endl;
}
};
class MarineAnimals {
public:
void output1() {
cout << "I am a marine animal" << endl;
}
};

class BlueWhale : public Mammals, public MarineAnimals {


public:
void output2() {
cout << "I belong to both the categories: Mammals as well as
Marine Animals" << endl;
}
};

int main()
{
Mammals m;
MarineAnimals ma;
BlueWhale bw;
m.output();
ma.output1();
bw.output2();
bw.output();
bw.output1();
return 0;
}

OUTPUT:

TASK 3:
Source Code:
#include<iostream>
using namespace std;
class Person
{
public:
Person(){
cout<<"a";
}
Person(int x)
{
cout<<"Person invoked"<<endl;
}
};

class Faculty:virtual public Person


{
public:
Faculty(int x): Person(x)
{
cout<<"Faculty invoked"<<endl;
}
};
class Student:virtual public Person
{
public:
Student(int x): Person(x)
{
cout<<"Student invoked"<<endl;
}
};
class TA:public Faculty,public Student
{
public:
TA(int x):Faculty(x),Student(x){
cout<<"TA invoked"<<endl;
}
};
int main()
{
TA t(30);
return 0;
}

OUTPUT:
----------------------------------------------------------------------------------------------

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy