#include <iostream.h>
#include <string.h>
/*----------------------Class Interfaces-------------------------*/
class Account
{
int number;
char name[10];
public :
void set(int, char*);
void display();
};
class SavingsAccount : public Account
{
int balance;
public:
void set(int,char*,int);// Overriding functions
void display();
};
class Deposite
{
int amount;
char maturity_date[9];
public:
void set(int, char*);
void display();
};
class DepositeAccount : public Account, public Deposite
{
char opening_date[9];
public:
void set(int,char*,int,char*,char*);// Overriding functions
void display();
};
class ShortTerm : public DepositeAccount
{
int no_of_months;
public:
void set(int,char*,int,char*,char*,int);// Overriding functions
void display();
};
class LongTerm : public DepositeAccount
{
int no_of_years;
int loan_taken;
public:
void set(int,char*,int,char*,char*,int,int);// Overriding functions
void display();
};
/*----------------------Class Implementations---------------------*/
// member function definitions for 'Account'
void Account::set(int a, char* b)
{
number = a;
strcpy(name, b);
}
void Account::display()
{
cout << "Number : " << number << "\n";
cout << "Name : " << name << "\n";
}
// member function definitions for 'SavingsAccount'
void SavingsAccount::set(int a, char* b, int c)
{
Account::set(a,b);
balance = c;
}
void SavingsAccount::display()
{
cout << "Savings Account Details --- \n";
Account::display();
cout << "Balance : " << balance << "\n";
}
// member function definitions for 'Deposite'
void Deposite::set(int a, char* b)
{
amount = a;
strcpy(maturity_date, b);
}
void Deposite::display()
{
cout << "Amount : " << amount << "\n";
cout << "Maturity Date : " << maturity_date << "\n";
}
// member function definitions for 'DepositeAccount'
void DepositeAccount::set(int a, char* b, int c, char* d, char* e)
{
Account::set(a,b);
Deposite::set(c,d);
strcpy(opening_date, e);
}
void DepositeAccount::display()
{
Account::display();
Deposite::display();
cout << "Date of Opening : " << opening_date << "\n";
}
// member function definitions for 'ShortTerm'
void ShortTerm::set(int a, char* b, int c, char* d, char* e, int f)
{
DepositeAccount::set(a,b,c,d,e);
no_of_months = f;
}
void ShortTerm::display()
{
cout << "Short Term Deposite Account Details --- \n";
DepositeAccount::display();
cout << "Duration in Months : " << no_of_months << "\n";
}
// member function definitions for 'LongTerm'
void LongTerm::set(int a, char* b, int c, char* d, char* e, int f, int g)
{
DepositeAccount::set(a,b,c,d,e);
no_of_years = f;
loan_taken = g;
}
void LongTerm::display()
{
cout << "Long Term Deposite Account Details --- \n";
DepositeAccount::display();
cout << "Duration in Years : " << no_of_years << "\n";
cout << "Loan Taken : " << loan_taken << "\n";
}
/*----------------------Class definitions ends here---------------*/
void main(void)
{
SavingsAccount S;
S.set(1323, "Stavan", 10000);
S.display();
cout << "\n";
ShortTerm ST;
ST.set(17099, "Kush", 25000, "12/05/02", "12/02/02", 3);
ST.display();
cout << "\n";
LongTerm LT;
LT.set(17169, "Vishwas", 30000, "15/03/04", "15/03/02", 2, 1000);
LT.display();
cout << "\n";
}
0 comments:
Post a Comment