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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
#include <iostream>
#include <iomanip>
#include <string>
#include <conio.h>
#include <stdio.h>
using namespace std;
#include "Header.h"
#include "Trans.h"
#include "Account.h"
#include "Source.h"
Customer* CreateCustomer(const string& name,
const string& userID, const string& pin)
{
Customer *customer = new Customer;
customer->userID = userID;
customer->name = name;
customer->pin = pin;
return customer;
}
Account* CreateAccount(Customer *customer,
const string &AccNum,
const string &AccDate,
const int &balance = 0,
const int &total_deposit = 0,
const int &total_withdrawal = 0,
const int &transx = 0)
{
Account *acc = new Account;
acc->Customer = customer;
acc->number = AccNum;
acc->date = AccDate;
acc->balance = balance;
acc->total_deposit = total_deposit;
acc->total_withdrawal = total_withdrawal;
// acc->transx;
return acc;
}
Transaction* CreateTransaction(Account *Customer,
const string& TransDate,
const string &TransDescription,
const double &TransAmount)
{
Transaction *transx = new Transaction;
transx->Account = Customer;
transx->TransDate = TransDate;
transx->TransDescription = TransDescription;
transx->TransAmount = TransAmount;
return transx;
}
Transaction* RecordDeposit(Account *Customer,
const string& TransDate,
const string &TransDescription,
const double &TransAmount)
{
Transaction *recordDeposit = new Transaction;
recordDeposit->Account = Customer;
recordDeposit->TransDate = TransDate;
recordDeposit->TransDescription = TransDescription;
recordDeposit->TransAmount += TransAmount;
return recordDeposit;
}
Transaction* RecordWithdraw(const string& TransDate,
const string &TransDescription,
const double &TransAmount)
{
Transaction *recordwithdrawal = new Transaction;
recordwithdrawal->TransDate = TransDate;
recordwithdrawal->TransDescription = TransDescription;
recordwithdrawal->TransAmount -= TransAmount;
return recordwithdrawal;
}
int main()
{
Customer* Mary = CreateCustomer("Mary Jones", "235718", "5074");
Customer* John = CreateCustomer("John Smith", "375864", "3251");
Account* MaryAccount = CreateAccount(Mary, "06-3121-10212357", "01/03/2014", 100);
Account* JohnAccount = CreateAccount(John, "06-3121-10213758", "10/03/2014");
Transaction* RecordDeposit = CreateTransaction (MaryAccount, "02/03/2014", "Deposit", 90);
Transaction* RecordWithdraw = CreateTransaction(MaryAccount, "04/03/2014", "ATM Withdrawal", 150);
//RecordWithdraw (MaryAccount("01/03/2014", "ATM Withdrawal", 50));
// RecordDeposit(MaryAccount, CreateTransaction("02/03/2014", "Deposit", 90);
//RecordWithdraw(MaryAccount, CreateTransaction("04/03/2014", "ATM Withdrawal", 150));
//RecordDeposit(MaryAccount, CreateTransaction("05/03/2014", "Deposit", 20));
//RecordWithdraw(MaryAccount, CreateTransaction("05/03/2014", "Withdraw", 100));
//RecordWithdraw(MaryAccount, CreateTransaction("05/03/2014", "Withdraw", 50));
/*
RecordDeposit(JohnAccount, CreateTransaction("11/03/2014", "Deposit", 20));
RecordDeposit(JohnAccount, CreateTransaction("12/03/2014", "Deposit", 80));
RecordWithdraw(JohnAccount, CreateTransaction("12/03/2014", "Withdraw", 50));
*/
printReport(MaryAccount);
printReport(JohnAccount);
_getch();
return 0;
}
|