Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Bank {
  6. protected:
  7.  
  8. string clientName;
  9. double balance;
  10. double percentage;
  11. int month;
  12.  
  13. public:
  14.  
  15. Bank (string clientName, double balance, double percentage, int month) {
  16. this -> clientName = clientName;
  17. this -> balance = balance;
  18. this -> percentage = percentage;
  19. this -> month = month;
  20. }
  21.  
  22. Bank () {
  23. this -> clientName = "";
  24. this -> balance = 0;
  25. this -> percentage = 0;
  26. this -> month = 0;
  27. }
  28. ~Bank () {
  29. cout<<"Destroying the bank object!"<<endl;
  30. }
  31.  
  32. void setClientName(string clientName) { this -> clientName = clientName;}
  33. string getClientName() { return clientName;}
  34.  
  35. void setBalance (double balance) {this -> balance = balance;}
  36. double getBalance () { return balance;}
  37.  
  38. void setPercentage (double percentage) { this -> percentage = percentage;}
  39. double getPercentage () {return percentage;}
  40.  
  41. void setMonth (int month) { this -> month = month;}
  42. int getMonth () { return month;}
  43.  
  44. void lihvaSize() {
  45. if (month < 0) {
  46. cout<<"Incorrect month input!"<<endl;
  47. } else {
  48. cout<<month*percentage;
  49. }
  50. }
  51.  
  52. };
  53.  
  54. class Deposit : public Bank {
  55.  
  56. public:
  57.  
  58. Deposit (string clientName, double balance, double percentage, int month) : Bank(clientName,balance, percentage, month){}
  59.  
  60. Deposit(){
  61. this -> clientName = "";
  62. this -> balance = 0;
  63. this -> percentage = 0;
  64. this -> month = 0;
  65. };
  66.  
  67. ~Deposit(){
  68. cout<<"Destroying the deposit object!"<<endl;
  69. }
  70. };
  71.  
  72. class Credit : public Bank {
  73. private:
  74.  
  75. double deposit;
  76.  
  77. public:
  78.  
  79. Credit (string clientName, double balance, double percentage, int month, double deposit) : Bank(clientName,balance, percentage, month) {
  80.  
  81. this -> deposit = deposit;
  82. }
  83.  
  84. ~Credit(){
  85. cout<<"Destroying the credit object!"<<endl;
  86. }
  87.  
  88. };
  89.  
  90. //void lihva (Bank& bank) {
  91. //cout<<"Lihva: "<< bank.lihvaSize();
  92. //}
  93.  
  94. int main () {
  95. Deposit d[2];
  96.  
  97. d[0].setClientName("Slavena");
  98. d[0].setBalance(50);
  99. d[0].setPercentage(3);
  100. d[0].setMonth(5);
  101. //lihva(d);
  102. cout<<"Name: "<<d[0].getClientName()<<" Balance: "<<d[0].getBalance()<<" Percentage: "<<d[0].getPercentage()<<" Month: "<<d[0].getMonth()<<endl;
  103.  
  104. return 0;
  105.  
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement