-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbankacct.h
107 lines (89 loc) · 2.87 KB
/
bankacct.h
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* -----------------------------------------------------------------------------
FILE: bankacct.h
DESCRIPTION: Header file for my project. Contains constants, structures, and classes needed for main program
COMPILER: g++ with c++ 11
MODIFICATION HISTORY:
Author Date Version
--------------- ---------- --------------
Alexander Novotny 2016-10-13 1.0.0
----------------------------------------------------------------------------- */
#ifndef __BANKACCT_H__
#define __BANKACCT_H__
//Semvers
#define VERSION "0.0.1"
#define FIRST_NAME_LENGTH 50
#define LAST_NAME_LENGTH 50
#define ACC_NUM_LENGTH 5
#define PASS_LENGTH 6
//This stuff defines how the menus looks (in case I want to change it later)
//I'm also doing this for purposes of literacy
//MIN_ and MAX_ defines how much the name and balance columns can stretch
//You shouldn't really mess around with MIN_
#define MIN_NAME 17
#define MAX_NAME 28
#define XTRA_NAME MAX_NAME - MIN_NAME
#define MIN_BAL 7
#define MAX_BAL 15
#define XTRA_BAL MAX_BAL - MIN_BAL
//This stuff should be constant - it's the width of each column
#define ACC_COL 7
#define SSN_COL 9
#define PHO_COL 12
#define MAX_VAR XTRA_NAME + XTRA_BAL
#define MIN_ROW 11
#define MAX_ROW 40
#define UI_ROWS 6
//Now this stuff is for the account menu
#define ACC_MIN_WIDTH 46
#define ACC_MIN_HEIGHT 10
#define ACC_MAIN_MIN 30
#define ACC_SEPARATION 7
//Transfer menu
#define TRANS_MIN_WIDTH 80
#define TRANS_MIN_HEIGHT 10
#define TRANS_MID_COL 10
//New Account Menu
#define NEWACC_LEFTSHIFT 20
using namespace std;
struct Account {
char first[FIRST_NAME_LENGTH + 1];
char last[LAST_NAME_LENGTH + 1];
char middle;
unsigned int social;
unsigned int area;
unsigned int phone;
double balance;
char number[ACC_NUM_LENGTH + 1];
char password[PASS_LENGTH + 1];
//Length of full name (including two spaces and a .)
unsigned int nameLength;
};
class WriteOnShutdown {
private:
const char* filename;
vector<Account>* database;
public:
WriteOnShutdown(char* a, vector<Account>* b) : filename(a), database(b) {}
/* -----------------------------------------------------------------------------
FUNCTION: ~WriteOnShutdown()
DESCRIPTION: Destructor for WriteOnShutdown. When WriteOnShutdown gets deleted,
it writes the database to the specified output file
RETURNS: Void function
----------------------------------------------------------------------------- */
~WriteOnShutdown() {
ofstream out(filename);
for(Account& acc : *database) {
out << acc.first << endl
<< acc.last << endl
<< acc.middle << endl
<< acc.social << endl
<< acc.area << endl
<< acc.phone << endl
<< acc.balance << endl
<< acc.number << endl
<< acc.password << endl << endl;
}
getch();
}
};
#endif