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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
#include <iostream>
#include <cctype>
using namespace std;
enum AccountType
{ unknown = -1, Checking, Savings, CreditCard, InstantAccess };
enum MenuType {
Main, CustomerMenu, EmployeeMenu, SupervisorMenu
};
enum MenuSelection {
None = -1,
Customer='1', Employee='2', Supervisor='3', // main menu options
Balance='a', Deposit, Withdrawal, Transfer, Other, // customer options
AddCustomer, DeleteCustomer, SearchCustomer, // employee options
CustomerCount, MoneyTotal, DailyDepositTotal, // supervisor options
DailyWithdrawalTotal, TransactionLog,
Quit='q'
};
struct customerInfo {
char firstName[20];
char lastName[20];
float amount;
AccountType type;
} customerInfo[100];
MenuSelection menu(const MenuType);
void menuAction(const MenuSelection);
int main(int argc, char *argv[]) {
MenuSelection menuSel = None;
while (menuSel != Quit) {
switch (menuSel = menu(Main)) {
case Customer:
menuAction(menuSel = menu(CustomerMenu));
break;
case Employee:
menuAction(menuSel = menu(EmployeeMenu));
break;
case Supervisor:
menuAction(menuSel = menu(SupervisorMenu));
break;
case Quit:
cout << "You have chosen to quit, we appreciate your business.";
break;
default:
cout << "You have entered an invalid option, please try again." << endl;
break;
}
}
return 0;
}
MenuSelection menu(const MenuType menu) {
char opt = (menu == Main) ? '1' : 'A';
char choice;
switch (menu) {
case Main:
cout << "Welcome To the Bank!" << endl;
cout << "Please enter an option." << endl;
cout << " " << opt << ") Customer" << endl;
cout << " " << char(++opt) << ") Bank Employee" << endl;
cout << " " << char(++opt) << ") Bank Supervisor" << endl;
break;
case CustomerMenu:
case EmployeeMenu:
case SupervisorMenu:
if (menu == CustomerMenu) {
cout << "Customer ";
} else if (menu == EmployeeMenu) {
cout << "Employee ";
} else if (menu == SupervisorMenu) {
cout << "Supervisor ";
}
cout << "Services" << endl;
cout << "Please enter an option:" << endl << endl;
cout << " " << opt << ") Balance Inquiry" << endl;
cout << " " << char(++opt) << ") Deposit Funds" << endl;
cout << " " << char(++opt) << ") Withdraw funds" << endl;
cout << " " << char(++opt) << ") Transfer Funds" << endl;
cout << " " << char(++opt) << ") Other" << endl;
if ((menu == EmployeeMenu) || (menu == SupervisorMenu)) {
cout << " " << char(++opt) << ") Add a new Customer to the Bank" << endl;
cout << " " << char(++opt) << ") Delete a Customer from the Bank" << endl;
cout << " " << char(++opt) << ") Search for a customer's Record" << endl;
}
if (menu == SupervisorMenu) {
cout << " " << char(++opt) << ") Total Customers in Bank" << endl;
cout << " " << char(++opt) << ") Total Money in the Bank" << endl;
cout << " " << char(++opt) << ") Total Deposits in a Day" << endl;
cout << " " << char(++opt) << ") Total Withdrawals in a Day" << endl;
cout << " " << char(++opt) << ") Log of all transactions" << endl;
}
break;
};
cout << " Q) Quit the application." << endl << "> ";
cin >> choice;
return static_cast<MenuSelection>( tolower(choice) );
}
void menuAction(const MenuSelection menuSel) {
switch (menuSel) {
case Balance:
cout << "balance inquiry tbd" << endl;
break;
case Deposit:
cout << "deposit tbd" << endl;
break;
case Withdrawal:
cout << "withdrawal tbd" << endl;
break;
case Transfer:
cout << "transfer tbd" << endl;
break;
case Other:
cout << "other tbd" << endl;
break;
case AddCustomer:
cout << "add customer tbd." << endl;
break;
case SearchCustomer:
cout << "search customer tbd." << endl;
break;
case DeleteCustomer:
cout << "delete customer tbd." << endl;
break;
case CustomerCount:
cout << "customer count tbd." << endl;
break;
case MoneyTotal:
cout << "money total tbd." << endl;
break;
case DailyDepositTotal:
cout << "deposit total tbd." << endl;
break;
case DailyWithdrawalTotal:
cout << "withdrawal total tbd." << endl;
break;
case TransactionLog:
cout << "transaction log tbd." << endl;
break;
case Quit:
cout << "You have chosen to quit, we appreciate your business.";
break;
default:
cout << "You have entered an invalid option, please try again." << endl;;
break;
}
}
| |