Vous êtes sur la page 1sur 10

OOP LAB 6 REPORT

HASSAN ALI
HAROON JAVED
MUHAMMAD SHAHROZ

(180423, 180445, 180467)


TASK 1:

#include<iostream>

using namespace std;


class Account

{
public:

double balance[5],balance1,balance2,deb,cred;

int j=0;

string pass[5],pass1;
Account()
{

for(int i=0;i<5;i++)
{

balance[i]=1000;

}
}

virtual void debit();

virtual void credit();


virtual void New();

};
class CreditCardAccount : public Account

{
public:

void ResetPin()

int e;

cout<<"Enter account number: ";

cin>>e;
cout<<"Enter password: ";
cin>>pass1;

if(pass[e]==pass1)
{

cout<<"Enter password: ";

cin>>pass[e];

virtual void New()


{

if(j>5)

cout<<"Cannot create new account";

else
{

cout<<"Enter password: ";


cout<<pass[j];
cout<<"Your account number is: ";

j++;

}
virtual void debit()
{

cout<<"Enter password: ";

cin>>pass1;

cout<<"Enter amount: ";


for(int i=0;i<5;i++)

if(pass1==pass[i])
{

cout<<"Enter amount of withdraw: ";

cin>>deb;
if(balance[i]<=deb)
{

balance1=balance[i]-deb;

cout<<"New amount is: "<<balance1;

else

{
cout<<"Amount exceeds balance";

virtual void credit()


{

cout<<"Enter password: ";


cin>>pass1;
cout<<"Enter amount: ";

for(int i=0;i<5;i++)

if(pass1==pass[i])
{
cout<<"Enter amount of withdraw: ";

cin>>cred;

balance2=balance[i]+cred;

cout<<"New amount is: "<<balance2;


}

}
};

class CheckingAccount : public Account

{
public:
int check;

virtual void New()

if(j>5)

cout<<"Cannot create new account";


}

else

cout<<"Enter password: ";

cout<<pass[j];

cout<<"Your account number is: ";


j++;

}
}
virtual void debit()

cout<<"Enter amount: ";

cin>>pass1;
for(int i=0;i<5;i++)
{

if(pass1==pass[i])

cout<<"Enter amount of withdraw: ";


cin>>deb;

if(balance[i]<=deb)

{
balance1=balance[i]-deb;

balance1=balance1-check;

cout<<"New amount is: "<<balance1<<" with amount taken


10 additionaly for transaction";
}
else

cout<<"Amount exceeds balance";

}
}

virtual void credit()

cout<<"Enter password: ";

cin>>pass1;

cout<<"Enter amount: ";


for(int i=0;i<5;i++)

{
if(pass1==pass[i])
{

cout<<"Enter amount of withdraw: ";

cin>>cred;

balance2=balance[i]+cred;
balance2=balance2-check;
cout<<"New amount is: "<<balance2<<" with amount 10 taken
additionally for transaction";
}

};

int main()

int y,t;
cout<<"Credit Card account (1) OR Checking account (2)";

cin>>y;
CreditCardAccount *c;
CheckingAccount *d;

if(y==1)

{a:

c->New();

cout<<endl;

cout<<"Deposit (1) OR Withdraw (2) OR Reset Password (3) OR Exit (4)";


cin>>t;

if(t==1)

c->credit();

goto a;

}
else if(t==2)

{
c->debit();
goto a;

else if(t==3)

{
c->ResetPin();
goto a;

else if(t==4)

{
exit(0);

}
else if(t==2)

{b:

d->New();
cout<<endl;
cout<<"Deposit (1) OR Withdraw (2) OR Exit (3)";

cin>>t;

if(t==1)

d->credit();

goto b;
}

else if(t==2)

d->debit();

goto b;

}
else if(t==3)

{
exit(0);
}

return 0;

RESULT:

Invalid output despite no error! (Probable compiler issue)

TASK 2:

#include<iostream>

using namespace std;

class Mammals
{

public:

virtual void mammal()


{
cout<<"I'm a Mammal";

virtual void Marine()

cout<<"I'm a marine Animal";

}
virtual void Both()

cout<<"I belong to both categories";

};

class MarineAnimals
{

public:
virtual void mammal()
{

cout<<"I'm a Mammal";

virtual void Marine()


{
cout<<"I'm a marine Animal";

virtual void Both()

{
cout<<"I belong to both categories";

};
class BlueWhale :public Mammals, public MarineAnimals

public:
};
int main()

Mammals a;

MarineAnimals b;

BlueWhale c;

a.mammal();
cout<<endl;

b.Marine();

cout<<endl;

Mammals* ptr = &c;

ptr->Both();

return 0;
}

RESULT: