Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Bank {
- protected:
- string clientName;
- double balance;
- double percentage;
- int month;
- public:
- Bank (string clientName, double balance, double percentage, int month) {
- this -> clientName = clientName;
- this -> balance = balance;
- this -> percentage = percentage;
- this -> month = month;
- }
- Bank () {
- this -> clientName = "";
- this -> balance = 0;
- this -> percentage = 0;
- this -> month = 0;
- }
- ~Bank () {
- cout<<"Destroying the bank object!"<<endl;
- }
- void setClientName(string clientName) { this -> clientName = clientName;}
- string getClientName() { return clientName;}
- void setBalance (double balance) {this -> balance = balance;}
- double getBalance () { return balance;}
- void setPercentage (double percentage) { this -> percentage = percentage;}
- double getPercentage () {return percentage;}
- void setMonth (int month) { this -> month = month;}
- int getMonth () { return month;}
- void lihvaSize() {
- if (month < 0) {
- cout<<"Incorrect month input!"<<endl;
- } else {
- cout<<month*percentage;
- }
- }
- };
- class Deposit : public Bank {
- public:
- Deposit (string clientName, double balance, double percentage, int month) : Bank(clientName,balance, percentage, month){}
- Deposit(){
- this -> clientName = "";
- this -> balance = 0;
- this -> percentage = 0;
- this -> month = 0;
- };
- ~Deposit(){
- cout<<"Destroying the deposit object!"<<endl;
- }
- };
- class Credit : public Bank {
- private:
- double deposit;
- public:
- Credit (string clientName, double balance, double percentage, int month, double deposit) : Bank(clientName,balance, percentage, month) {
- this -> deposit = deposit;
- }
- ~Credit(){
- cout<<"Destroying the credit object!"<<endl;
- }
- };
- //void lihva (Bank& bank) {
- //cout<<"Lihva: "<< bank.lihvaSize();
- //}
- int main () {
- Deposit d[2];
- d[0].setClientName("Slavena");
- d[0].setBalance(50);
- d[0].setPercentage(3);
- d[0].setMonth(5);
- //lihva(d);
- cout<<"Name: "<<d[0].getClientName()<<" Balance: "<<d[0].getBalance()<<" Percentage: "<<d[0].getPercentage()<<" Month: "<<d[0].getMonth()<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement