Advertisement
Guest User

a

a guest
Feb 17th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. class Client
  6. {
  7.     std::string name;
  8.     std::vector<Account *> Accounts;
  9. public:
  10.     void SetName(std::string n)
  11.     {
  12.         name = n;
  13.     }
  14.     std::string GetName()
  15.     {
  16.         return this->name;
  17.     }
  18.     void AddAccount(Account * a)
  19.     {
  20.         Accounts.push_back(a);
  21.     }
  22.     Client(std::string a)
  23.     {
  24.         name = a;
  25.     }
  26. };
  27.  
  28. class Account : public IAccount
  29. {
  30.     unsigned int id;
  31.     std::string password;
  32.     unsigned long long cash = 0;
  33.     Client & client;
  34. public:
  35.     void AddMoney(unsigned long long money)
  36.     {
  37.         this->cash += money;
  38.     }
  39.     void Withdraw(unsigned long long money)
  40.     {
  41.         if (money > GetBalance())
  42.             return;
  43.         this->cash -= money;
  44.     }
  45.     unsigned long long GetBalance()
  46.     {
  47.         return this->cash;
  48.     }
  49.     unsigned int GetID()
  50.     {
  51.         return this->id;
  52.     }
  53.     Account(unsigned int id, std::string passwd, Client * cli) : id(id), password(passwd), client(*cli)
  54.     {
  55.        
  56.     }
  57. };
  58.  
  59. __interface IAccount
  60. {
  61. public:
  62.     bool CheckAccess(int id, std::string p);
  63.     unsigned long long GetBalance();
  64.     void Withdraw();
  65. };
  66.  
  67.  
  68.  
  69.  
  70. class Bank : public Bankomat
  71. {
  72.     std::vector<Account *> accounts;
  73. public:
  74.     void AddAccount(Account * a)
  75.     {
  76.         accounts.push_back(a);
  77.     }
  78.     std::vector<Account *> GetAccounts()
  79.     {
  80.         return accounts;
  81.     }
  82. };
  83.  
  84. class Bankomat : public IAccount
  85. {
  86.     Bank * bank;
  87. public:
  88.     bool CheckAccess(int id, std::string p) override
  89.     {
  90.         for (int i = 0; i < bank->GetAccounts().size(); i++)
  91.         {
  92.             if (bank->GetAccounts()[i]->GetID() == id)
  93.                
  94.         }
  95.     }
  96. };
  97.  
  98.  
  99.  
  100. void main()
  101. {
  102.    
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement