-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.h
More file actions
77 lines (51 loc) · 2.31 KB
/
Account.h
File metadata and controls
77 lines (51 loc) · 2.31 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// VirtualTau assumption:
// 1. Implement a Factory method or Factory class is permitted
// 2. There is no need to implement the exact time of Account creation, indicating only the years is enough.
//
#ifndef __ACCOUNT_H__
#define __ACCOUNT_H__
#include <string>
using namespace std;
class AccountImpl;
//ENUMS
enum Account_Type{ //enum of the Account types
TWOYEARS, //is allowed to close any time after 2 years
FAMILY, //can be managed by all family members ( family accounts )
STOCKEXCHANGE}; //deposit is allowed to invest in Stock Exchange
enum Operation { //enum of the Account operations
DEPOSIT, //deposit cash in the account
WITHDRAWAL, //withdrawal cash from the account
DEPOSITSTOCK, //invest in the stock market
NOTIFY, //send message to the account owners
CLOSE}; //close the account
enum Period {THREE=3,SEVEN=7,TEN=10} ; //Enum represent the saving period (in years)
//ABC representing account
//using Bridge Design pattern for its implementation those holds a Factory of different account implementations
//Observer of tBank_t
class Account {
public:
Account(Account_Type type, int date, Period period, float PrecentOnDeposite, int id); //CTOR
~Account(); //DTOR
//Observer method
void Update(Operation operation, int amount, string msg); //update the account state
friend ostream &operator<< (ostream &os, Account &acc); //report of the current account
int getType() const;
int getDate() const;
Period getPeriod() const;
private:
Account(const Account &t); //Prevent COPY
Account &operator=(const Account &t); //Prevent COPY
//Member//
AccountImpl* m_Account; //Instance of the Account Implementation
//Factory Method//
AccountImpl* AccountFactory(Account_Type type, int date, Period period, float PrecentOnDeposite, int id); //AccountImpl Factory
//Operation Methods
void deposit(int amount); //deposit cash in the account
void withdraw(int amount); //withdraw cash from the account
void depositStock(int amount); //deposit an investment in the stock market
void notify(string msg); //notify the account by a massage
//Other Operations//
void close(int currentDate); //close the account
};
#endif