-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.h
More file actions
56 lines (35 loc) · 1.45 KB
/
Bank.h
File metadata and controls
56 lines (35 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef __BANK_H__
#define __BANK_H__
#include <vector>
#include "Account.h"
#include <string>
using namespace std;
class Account;
//An object representing a bank.
//This object is a:
// 1. Singleton and cannot be created more than once per program
// 2. Subject and can be observed by the accounts
class Bank{
public:
static Bank& Instance() {return m_bank;} //get reference to the bank instance
//Subject Methods//
void Attach(Account* acc); //add observer to observer list
void Detach(Account* acc); //remove observer from observer list
Account *createNewAccount(int type, int date, int period, float PrecentOnDeposite); //Create a new account and attach to bank
friend ostream &operator<< (ostream &os, Bank &bank); //report of the current bank
//Observer notifications
void InvestInStockExchange(int amount); //Invest in stock exchange
void GiveFamilyBonus();
void Notify(); //notify all observer to come
void deposit(int id, int amount); //Deposit amount in account
void withdraw(int id, int amount); //Withdraw amount from account
private:
Bank(); //Private CTOR in order to disable instantiation
~Bank(); //DTOR - Deletes all accounts in bank
Bank(const Bank &bank); //Prevent COPY
Bank &operator=(const Bank &bank); //Prevent COPY
static Bank m_bank; //Singleton static object
//Data Members//
vector<Account*> m_accounts; //observers Vector
};
#endif