#pragma once #include #include #include class Bank; class Client; class Employee; class Gov; class Gov { public: static const int FACTOR = 6; // Money multiplier. int rate = 2; // Interest rate (%). bool associate (Bank *const x); double reserveDeposit (Bank &x, const double amount); double reserveWithdraw (Bank &x, const double amount); bool bailout (Bank &x, const double amount); double getReserve (); private: time_t lastBailout = 0; // Time since last bailout. double reserve = 0; // Total in bank reserves. std::vector banks; }; class Bank { friend class Gov; public: Bank (Gov *x) : centralBank (x) { x->associate (this); }; // Must have Gov. double deposit (Client &x, const double amount); double withdraw (Client &x, const double amount); double getCurrent (); double getCurrent (const Client &x); double getCreditable (); double getCredited (); bool hire (Employee &x); bool fire (Employee &x); bool openAccount (Client &x); bool closeAccount (Client &x); void closeAccountNoBail (Client &x); // TODO: implement loans, for now there is placeholder loan() and unloan(), // in order to simulate loaning and test bailout mechanism. // bool newCredit (const std::string id, const double amount, // const int installments, const int days, // const float interest); // double payInstallment (const int index); auto countEmployees (); auto countClients (); bool loan (const double amount); bool unloan (const double amount); private: Gov *centralBank; const int CLIENT_EMPLOYEE = 2; // Max number of clients to employees. double current = 0; // Total current accts. of clients. double creditable = 0; // Amount able to be loaned to clients. double credited = 0; // Amount loaned. struct creditRecord // TODO: implement loans, currently this struct is a dud. { // time_t start; // long interval; // Interval of payments in number of seconds. // double amount; // int installments; // float interest; }; struct clientRecord { std::string id; double current = 0; std::vector loans; }; std::vector clients; std::vector employees; }; class Employee { friend class Bank; public: std::string name; Employee (std::string x) : name (x){}; ~Employee (); private: Bank *employer = nullptr; }; class Client { friend class Bank; public: std::string id; Client (std::string x) : id (x), underMattress (0){}; ~Client (); double earn (const double amount); // Earn money. double getMattress (); private: double underMattress; std::vector accounts; };