Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Jesufarahanmi Fadamiro
- //Youtube
- // G++ Project#2-1
- //Projedt#2.cpp
- #include <iostream>
- #include <vector>
- #include <string>
- #include <fstream>
- #include <ostream>
- #include <array>
- using namespace std;
- class menu;
- class admin;
- class member;
- class client;
- class account;
- int const databasesize = 50;
- class menu {
- public:
- menu();
- void seeMain();
- void membermenu();
- void seeuserlogin();
- bool certification(string, string, vector <member>);
- void showAdminMenu();
- void showrequest();
- member returnmember(string, string, vector <member>);
- };
- class admin {
- public:
- admin();
- string name;
- string password;
- int verify;
- void setadminname(string);
- void setadminpass(string);
- string getadminname(string);
- string getadminpass(string);
- int getverify();
- void setverify(int);
- void addnewmember(vector <member>&);
- void deletemember(vector <member>&);
- void displaybranch(vector <member>);
- void changepassword(member, vector <member>&);
- };
- class member {
- public:
- member();
- string name;
- string password;
- void setuserMemberInfo(string);
- void setuserpassword(string);
- void changeuserpass(member, vector <member>&);
- void addmember(string, string, int, string, int, vector <client>);
- string getmembername();
- string getuserpassword();
- int getverification();
- void setverification(int);
- int verification = 0;
- };
- class account {
- public:
- account();
- int useracctnum;
- string name;
- string useracctype;
- int userbalance;
- void setuseracctname(string);
- void setuseraccttype(string);
- void setuseracctbalance(int);
- void setuseracctnum(int);
- string getuseracctname();
- string getuseraccttype();
- int getuserbalance();
- int getuseracctnum();
- int getuserverification();
- void setuserverification(int);
- void userdeposit(int);
- void userwithdraw(int);
- int verification = 0;
- };
- class client {
- public:
- client();
- account clientaccount;
- class account;
- string userclientname;
- string useraddress;
- int userssninfo;
- string useremployerinfo;
- int userincomeinfo;
- void setuserclientname(string);
- void setuseraddress(string);
- void setuserssninfo(int);
- void setuseremployerinfo(string);
- void setuserincomeinfo(int);
- string getclientnameinfo();
- string getuseraddressinfo();
- int getuserssn();
- string getuseremployer();
- int getuserincome();
- int getverification();
- void setverification(int);
- int verification = 0;
- };
- menu::menu() {
- }
- admin::admin(){
- string username = "NA";
- string userpassword = "NA";
- int verification = 0;
- }
- member::member() {
- string username = "NA";
- string userpassword = "NA";
- int verification = 0;
- }
- client::client() {
- string userclientname = "NA";
- string useraddress = "NA";
- int userssninfo = 0;
- string employerinfo = "NA";
- int userincomeinfo = 0;
- int verification = 0;
- }
- account::account() {
- int useracctnum = 0;
- string username = "NA";
- string useraccttype = "NA";
- int userbalance = 0;
- int verification = 0;
- }
- void menu::seeMain() {
- cout << "\t===========================================================\n";
- cout << "\t| Welcome to the Auburn Branch of Tiger Bank! |\n";
- cout << "\t===========================================================\n";
- cout << "1) Login\n";
- cout << "2) Quit\n";
- }
- bool menu::certification(string nameIn, string passIn, vector <member> database){
- bool valid = false;
- int index;
- for(index = 0; index < databasesize; index++){
- if(database[index].getmembername() == nameIn && database[index].getuserpassword() == passIn){
- valid = true;
- break;
- }
- else {
- valid = false;
- }
- }
- return valid;
- }
- void menu::seeuserlogin() {
- cout << "\t===========================================================\n";
- cout << "\t| Login to Access the Teller Terminal System |\n";
- cout << "\t===========================================================\n";
- }
- member menu::returnmember(string nameIn, string passIn, vector <member> database){
- member retrieve;
- for(int index = 0; index < databasesize; index++){
- if(database[index].getmembername() == nameIn && database[index].getuserpassword() == passIn){
- retrieve.setverification(database[index].getverification());
- retrieve.setuserpassword(database[index].getuserpassword());
- retrieve.setuserMemberInfo(database[index].getmembername());
- break;
- }
- }
- return retrieve;
- }
- void menu::showAdminMenu() {
- cout << "\t===========================================================\n";
- cout << "\t| Teller Terminal System – System Administration |\n";
- cout << "\t===========================================================\n";
- cout << "1) Client and Account Management\n";
- cout << "2) Add a branch staff member\n";
- cout << "3) Delete a branch staff member\n";
- cout << "4) Display branch staff\n";
- cout << "5) Change password\n";
- cout << "6) Exit\n";
- cout << "\tPlease choose an option: ";
- }
- void admin::setadminname(string nameIn) {
- name = nameIn;
- }
- void admin::setadminpass(string passwordIn) {
- password = passwordIn;
- }
- void admin::changepassword(member currentmemberinfo, vector <member>& database) {
- string passIn;
- do{
- cout << "New Password: ";
- cin >> passIn;
- if (passIn == currentmemberinfo.getuserpassword()){
- cout << "Error - Your new password must be different from the old one.\n";
- }
- }while (passIn == currentmemberinfo.getuserpassword());
- currentmemberinfo.setuserpassword(passIn);
- for(int index = 0; index < databasesize; index++){
- if(database[index].getmembername() == currentmemberinfo.getmembername()){
- database[index] = currentmemberinfo;
- break;
- }
- }
- }
- void admin::addnewmember(vector <member>& database) {
- member newmember;
- string nameIn;
- string passIn;
- int verifyIn;
- cout << "Username: ";
- cin >> nameIn;
- newmember.setuserMemberInfo(nameIn);
- cout << "Password: ";
- cin >> passIn;
- newmember.setuserpassword(passIn);
- cout << "Role (1 - Administrator; 2 - Branch Staff): ";
- cin >> verifyIn;
- newmember.setverification(verifyIn);
- int index;
- for(index = 0; index < databasesize; index++){
- if(database[index].getverification() == 0){
- database[index] = newmember;
- if(newmember.getverification() == 1){
- cout << "User Name: " << nameIn << " Role: System Administrator\n";
- }
- else{
- cout << "User Name: " << nameIn << " Role: Branch Staff\n";
- }
- break;
- }
- else if(index == databasesize - 1 && database[index].getverification() != 0){
- cout << "We apologize. The database seems to be full\n";
- break;
- }
- }
- }
- void admin::deletemember(vector <member>& database) {
- member empty_member;
- string nameIn;
- int choice;
- cout << "Delete a user - User Name: ";
- cin >> nameIn;
- cout << "3) Confirm\n";
- cout << "4) Cancel\n";
- cout << "Please choose an option: ";
- cin >> choice;
- switch(choice){
- case 3:
- for(int index = 0; index < databasesize; index++){
- if(database[index].getmembername() == nameIn){
- database[index] = empty_member;
- cout << "User " << nameIn << " was deleted.\n";
- break;
- }
- else if(index == databasesize - 1){
- cout << "Error - User was not found in the system.\n";
- }
- }
- break;
- case 4:
- break;
- }
- }
- void admin::displaybranch(vector <member> database) {
- for (int index = 0; index < databasesize; index++) {
- if (database[index].getverification() != 0) {
- if (database[index].getverification() == 1) {
- cout << "User Name: " << database[index].getmembername() << " Role: Administrator\n";
- }
- else if(database[index].getverification() == 2){
- cout << "User Name: " << database[index].getmembername() << " Role: Branch Staff\n";
- }
- }
- }
- }
- string member::getmembername() {
- return name;
- }
- string member::getuserpassword() {
- return password;
- }
- int member::getverification() {
- return verification;
- }
- int account::getuserverification() {
- return verification;
- }
- int client::getverification() {
- return getverification();
- }
- void member::setverification(int verifyIn) {
- verification = verifyIn;
- }
- void client::setverification(int verifyIn) {
- verification = verifyIn;
- }
- void account::setuserverification(int verifyIn) {
- verification = verifyIn;
- }
- void admin::setverify(int verifyIn) {
- verify = verifyIn;
- }
- string admin::getadminname(string) {
- return name;
- }
- string admin::getadminpass(string) {
- return password;
- }
- void member::setuserMemberInfo(string nameIn){
- name = nameIn;
- }
- void member::setuserpassword(string passwordIn){
- password = passwordIn;
- }
- void member::changeuserpass(member currentmemberinfo, vector <member>& database) {
- string passIn;
- do{
- cout << "New Password: ";
- cin >> passIn;
- if (passIn == currentmemberinfo.getuserpassword()){
- cout << "Error - Your new password must be different from the old one.\n";
- }
- }while (passIn == currentmemberinfo.getuserpassword());
- currentmemberinfo.setuserpassword(passIn);
- for(int index = 0; index < databasesize; index++){
- if (database[index].getmembername() == currentmemberinfo.getmembername()){
- database[index] = currentmemberinfo;
- }
- }
- }
- void menu::membermenu(){
- cout << "=============================================================\n";
- cout << "| Teller Terminal System – Branch Staff |\n";
- cout << "=============================================================\n";
- cout << "1) Client and Account Management\n";
- cout << "2) Change password\n";
- cout << "3) Exit\n";
- cout << "Please choose an option: ";
- }
- void menu::showrequest() {
- cout << "=============================================================\n";
- cout << "| Teller Terminal System – Client and Account Management |\n";
- cout << "=============================================================\n";
- cout << "1) Add a client\n";
- cout << "2) Add an account\n";
- cout << "3) Edit Client Information\n";
- cout << "4) Manage an account\n";
- cout << "5) Save Client and Account Information\n";
- cout << "6) Exit\n";
- cout << "Please choose an option: ";
- }
- void addclient(vector <client>& clientdatabase){
- string nameIn;
- string addressIn;
- int ssnIn;
- string employerIn;
- int incomeIn;
- cout << "A new client will be added: \n";
- client newclient;
- cout << "Client name: ";
- cin >> nameIn;
- newclient.setuserclientname(nameIn);
- cout << "Address: ";
- cin >> addressIn;
- newclient.setuseraddress(addressIn);
- cout << "Social Security Number: ";
- cin >> ssnIn;
- newclient.setuserssninfo(ssnIn);
- cout << "Employer: ";
- cin >> employerIn;
- newclient.setuseremployerinfo(employerIn);
- cout << "Annual Income: ";
- cin >> incomeIn;
- newclient.setuserincomeinfo(incomeIn);
- for(int index = 0; index < databasesize; index++){
- if(clientdatabase[index].getverification() == 0){
- newclient.setverification(1);
- clientdatabase[index] = newclient;
- cout << "A new client was added!\n";
- break;
- }
- else if(index == databasesize - 1 && clientdatabase[index].getverification() != 0){
- "We apologize. The database seems to be full\n";
- break;
- }
- }
- }
- void addaccount(vector <client>& clientdatabase, vector <account>& accountdatabase){
- string clientnameIn;
- int acctnumIn;
- string acctypeIn;
- int balanceIn;
- cout << "Choose a client: ";
- cin >> clientnameIn;
- for(int index = 0; index < databasesize; index++){
- if(clientdatabase[index].getclientnameinfo() == clientnameIn){
- cout << "A new account will be created for " << clientdatabase[index].getclientnameinfo() << "....\n";
- account newaccount;
- newaccount.setuserverification(1);
- cout << "Account Number: ";
- cin >> acctnumIn;
- newaccount.setuseracctnum(acctnumIn);
- cout << "Account Type: ";
- cin >> acctypeIn;
- newaccount.setuseraccttype(acctypeIn);
- cout << "Balance: ";
- cin >> balanceIn;
- newaccount.setuseracctbalance(balanceIn);
- newaccount.setuseracctname(clientdatabase[index].getclientnameinfo());
- for(int num = 0; num < databasesize; num++){
- if(accountdatabase[num].getuserverification() == 0){
- accountdatabase[num] = newaccount;
- cout << "A new account was created for " << accountdatabase[index].getuseracctname() << " \n";
- break;
- }
- else if(index == databasesize - 1 && accountdatabase[index].getuserverification() != 0){
- "We apologize. The database seems to be full\n";
- break;
- }
- }
- break;
- }
- else if(index == databasesize - 1){
- cout << "Error - The client is not in the system.\n";
- }
- }
- }
- void editclientinfo(vector <client>& clientdatabase){
- string clientnameIn;
- string newaddress;
- int newssn;
- string newemployer;
- int newannualincome;
- bool active = true;
- int choice = 0;
- cout << "Choose a client: ";
- cin >> clientnameIn;
- for(int index = 0; index < databasesize; index++){
- if(clientdatabase[index].getclientnameinfo() == clientnameIn){
- cout << "Display " << clientdatabase[index].getclientnameinfo() << "'s information: \n";
- cout << "Address: " << clientdatabase[index].getuseraddressinfo() << "\n";
- cout << "Social security number: " << clientdatabase[index].getuserssn() << "\n";
- cout << "Employer: " << clientdatabase[index].getuseremployer() << "\n";
- cout << "Annual Income: " << clientdatabase[index].getuserincome() << "\n";
- cout << "Client " << clientdatabase[index].getclientnameinfo() << "'s information will be updated...\n";
- cout << "1) Confirm\n";
- cout << "2) Cancel\n";
- cout << "Please choose an option: ";
- cin >> choice;
- switch(choice){
- case 1:
- cout << "Address: ";
- cin >> newaddress;
- clientdatabase[index].setuseraddress(newaddress);
- cout << "Social security number: ";
- cin >> newssn;
- clientdatabase[index].setuserssninfo(newssn);
- cout << "Employer: ";
- cin >> newemployer;
- clientdatabase[index].setuseremployerinfo(newemployer);
- cout << "Annual Income: ";
- cin >> newannualincome;
- clientdatabase[index].setuserincomeinfo(newannualincome);
- cout << "Client " << clientdatabase[index].getclientnameinfo() << "'s information was updated.\n";
- break;
- case 2:
- break;
- }
- break;
- }
- else if(index == databasesize - 1){
- cout << "Error - Account " << clientdatabase[index].getclientnameinfo() << " is not in the system.\n";
- }
- }
- }
- void manaccount(vector <account>& accountdatabase){
- int acctnumIn = 0;
- int choice = 0;
- int depositIn = 0;
- int withdrawIn = 0;
- bool inservice = true;
- cout << "Which account will be managed? ";
- cin >> acctnumIn;
- for(int num = 0; num < databasesize; num++){
- if(accountdatabase[num].getuseracctnum() == acctnumIn){
- do{
- cout << "Manage account " << accountdatabase[num].getuseracctnum() << " for " << accountdatabase[num].getuseracctnum() << "...\n";
- cout << "1) Deposit\n";
- cout << "2) Withdraw\n";
- cout << "3) Cancel\n";
- cout << "Please choose an option: ";
- cin >> choice;
- switch(choice){
- case 1:
- cout << "Deposit Amount: ";
- cin >> depositIn;
- accountdatabase[num].userdeposit(depositIn);
- cout << "Balance of account " << accountdatabase[num].getuseracctnum() << " is: " << accountdatabase[num].getuserbalance() << "\n";
- break;
- case 2:
- cout << "Withdraw Amount: ";
- cin >> withdrawIn;
- accountdatabase[num].userwithdraw(withdrawIn);
- cout << "Balance of account " << accountdatabase[num].getuseracctnum() << " is: " << accountdatabase[num].getuserbalance() << "\n";
- break;
- case 3:
- inservice = false;
- break;
- }
- }while(inservice == true);
- break;
- }
- else if(num == databasesize - 1){
- cout << "Error - Account " << acctnumIn << " is not in the system.\n";
- }
- }
- }
- void accountsaveinfo(account accountread){
- ofstream outFile;
- outFile.open("account-info.txt",ios::app);
- outFile << "Account name: "<< accountread.getuseracctname() << endl;
- outFile << "Balance: " << accountread.getuserbalance() << endl;
- outFile << "Account Type: "<< accountread.getuseraccttype() << endl;
- outFile << "Account Number: " << accountread.getuseracctnum() << endl;
- outFile.close();
- cout << "account information has been saved in the account-info file." << endl;
- }
- void clientsaveinfo(client clientread){
- ofstream outFile;
- outFile.open("client-info.txt", ios::app);
- outFile << "Client name: "<< clientread.getclientnameinfo() << endl;
- outFile << "Address: " << clientread.getuseraddressinfo() << endl;
- outFile << "Employer: " << clientread.getuseremployer() << endl;
- outFile << "Annual Income: " << clientread.getuserincome() << endl;
- outFile << "Social Security Number: " << clientread.getuserssn() << endl;
- outFile.close();
- cout << "Client information has been saved in the client-info file" << endl;
- }
- void systemquit(member staff){
- ofstream outfile;
- outfile.open("staffmembers.txt");
- outfile << "Name: " << staff.getmembername() << endl;
- outfile << "Password: " << staff.getuserpassword() << endl;
- if(staff.getverification() == 1){
- outfile << "Role: Admin" << endl;
- }
- else if(staff.getverification() == 2){
- outfile << "Role: Branch Staff" << endl;
- }
- outfile.close();
- }
- void account::setuseracctname(string nameIn) {
- name = nameIn;
- }
- void account::setuseracctnum(int numIn) {
- useracctnum = numIn;
- }
- void account::setuseracctbalance(int userbalanceIn) {
- userbalance = userbalanceIn;
- }
- void account::userdeposit(int userdepositIn){
- userbalance += userdepositIn;
- }
- void account::userwithdraw(int userwithdrawIn){
- if(userwithdrawIn > userbalance){
- cout << "Insufficient funds. Can not withdraw. ";
- }
- else{
- userbalance -= userwithdrawIn;
- }
- }
- void account::setuseraccttype(string typeIn) {
- getuseraccttype() = typeIn;
- }
- string account::getuseracctname() {
- return name;
- }
- string account::getuseraccttype() {
- return useracctype;
- }
- int account::getuserbalance() {
- return userbalance;
- }
- int account::getuseracctnum() {
- return useracctnum;
- }
- void client::setuseraddress(string addressIn) {
- useraddress = addressIn;
- }
- void client::setuserclientname(string nameIn) {
- userclientname = nameIn;
- }
- void client::setuseremployerinfo(string nameIn) {
- useremployerinfo = nameIn;
- }
- void client::setuserincomeinfo(int userincomeIn) {
- userincomeinfo = userincomeIn;
- }
- void client::setuserssninfo(int ssnIn) {
- userssninfo = ssnIn;
- }
- string client::getuseraddressinfo() {
- return useraddress;
- }
- string client::getclientnameinfo() {
- return userclientname;
- }
- string client::getuseremployer() {
- return useremployerinfo;
- }
- int client::getuserssn() {
- return userssninfo;
- }
- int client::getuserincome() {
- return userincomeinfo;
- }
- int main(){
- admin myadmin;
- member currentmemberinfo;
- member adminmember;
- vector <member> database(databasesize);
- vector <client> clientdatabase(databasesize);
- vector <account> accountdatabase(databasesize);
- adminmember.setuserMemberInfo("Jesufarahanmi");
- adminmember.setuserpassword("YungMacster");
- adminmember.setverification(1);
- database[0] = adminmember;
- menu Menu;
- string nameIn;
- string passIn;
- int userInput;
- char c;
- bool active = true;
- bool active1 = true;
- bool active2 = true;
- bool active3 = true;
- bool active4 = true;
- do {
- active = true;
- Menu.seeMain();
- cout << "\tPlease choose an option: ";
- cin >> userInput;
- switch(userInput){
- case 1:
- Menu.seeuserlogin();
- for(int attempts = 0; attempts < 3; attempts++){
- cout << "User Name: ";
- cin >> nameIn;
- cout << "Password: ";
- cin >> passIn;
- if(!Menu.certification(nameIn, passIn, database)){
- cout << "The user name or password is incorrect. Try again.\n";
- }
- else{
- currentmemberinfo.setuserMemberInfo(Menu.returnmember(nameIn, passIn, database).getmembername());
- currentmemberinfo.setuserpassword(Menu.returnmember(nameIn, passIn, database).getuserpassword());
- currentmemberinfo.setverification(Menu.returnmember(nameIn, passIn, database).getverification());
- if(currentmemberinfo.getverification() == 1){
- do{
- int choice;
- Menu.showAdminMenu();
- cin >> choice;
- switch(choice){
- case 1:
- do{
- Menu.showrequest();
- int choice1 = 0;
- cin >> choice1;
- switch(choice1){
- case 1:
- addclient(clientdatabase);
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active3 = true;
- break;
- case 2:
- addaccount(clientdatabase, accountdatabase);
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active3 = true;
- break;
- case 3:
- editclientinfo(clientdatabase);
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active3 = true;
- break;
- case 4:
- manaccount(accountdatabase);
- active3 = true;
- break;
- case 5:
- for(int index = 0; index < databasesize; index++){
- if(clientdatabase[index].getverification() == 1){
- clientsaveinfo(clientdatabase[index]);
- }
- }
- for(int index = 0; index < databasesize; index++){
- if(accountdatabase[index].getuserverification() == 1){
- accountsaveinfo(accountdatabase[index]);
- }
- }
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active3 = true;
- break;
- case 6:
- active3 = false;
- break;
- default:
- break;
- }
- }while(active3);
- active1 = true;
- break;
- case 2:
- myadmin.addnewmember(database);
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active1 = true;
- break;
- case 3:
- myadmin.deletemember(database);
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active1 = true;
- break;
- case 4:
- myadmin.displaybranch(database);
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active1 = true;
- break;
- case 5:
- myadmin.changepassword(currentmemberinfo, database);
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active1 = true;
- break;
- case 6:
- active1 = false;
- break;
- default:
- break;
- }
- }while(active1);
- break;
- }
- else if(currentmemberinfo.getverification() == 2){
- do{
- int choice;
- Menu.membermenu();
- cin >> choice;
- switch(choice){
- case 1:
- do{
- Menu.showrequest();
- int choice2 = 0;
- cin >> choice2;
- switch(choice2){
- case 1:
- addclient(clientdatabase);
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active4 = true;
- break;
- case 2:
- addaccount(clientdatabase, accountdatabase);
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active4 = true;
- break;
- case 3:
- editclientinfo(clientdatabase);
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active4 = true;
- break;
- case 4:
- manaccount(accountdatabase);
- active4 = true;
- break;
- case 5:
- for(int index = 0; index < databasesize; index++){
- if(clientdatabase[index].getverification() == 1){
- clientsaveinfo(clientdatabase[index]);
- }
- }
- for(int index = 0; index < databasesize; index++){
- if(accountdatabase[index].getuserverification() == 1){
- accountsaveinfo(accountdatabase[index]);
- }
- }
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active4 = true;
- break;
- case 6:
- active4 = false;
- default:
- break;
- }
- }while(active4);
- active2 = true;
- break;
- case 2:
- currentmemberinfo.changeuserpass(currentmemberinfo, database);
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active2 = true;
- break;
- case 3:
- active2 = false;
- break;
- default:
- break;
- }
- }while(active2);
- }
- break;
- }
- }
- active = true;
- break;
- case 2:
- for(int index = 0; index < databasesize; index++){
- if(database[index].getverification() > 0 && database[index].getverification() <= 2){
- systemquit(database[index]);
- }
- }
- cout << "Press any key to continue...\n";
- cin.ignore().get();
- active = false;
- break;
- default:
- break;
- }
- }while(active);
- return 0;
- }
Add Comment
Please, Sign In to add comment