-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBank.cxx
40 lines (34 loc) · 976 Bytes
/
Bank.cxx
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
#include "Bank.hxx"
#include "Account.hxx"
Bank::Bank() : myAccounts()
{
myCurrentAccountNumber = 0;
}
Bank::~Bank()
{
// NYI: Clean up account list
}
// Get acount number. Only return valid object if password is correct
Account* Bank::getAccount(int num, string password)
{
Account* userAccount = NULL;
if (myAccounts.size() > num)
{
userAccount = (Account*)myAccounts[num];
}
if ((userAccount != NULL) && (password.compare(userAccount->getPassword()) != 0))
{
// account wrong if account number does not match
userAccount = NULL;
}
// No account with this number/password exists!!!
return userAccount;
}
// Create a new account and return a reference to it
Account* Bank::addAccount()
{
Account* userAccount = new Account();
userAccount->setAccountNumber(myCurrentAccountNumber++);
myAccounts.push_back(userAccount);
return userAccount;
}