Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <stdlib.h>
- using namespace std;
- class Client{
- public:
- Client(int, string, string, string, string, double);
- void addAccount(float accountNum, string accType, float balance);
- string getName();
- string getEmployer();
- string getAddress();
- string getSSN();
- double getIncome();
- void setName(string newName);
- void setEmployer(string newEmployer);
- void setAddress(string newAddress);
- void setSSN(string newSSN);
- void setIncome(double newIncome);
- int getID();
- private:
- double income;
- int clientID;
- string name, employer, address, ssn;
- };
- class ClientVector
- {
- public:
- void addClient(Client inClient);
- vector<Client> clientList;
- void readIn();
- ClientVector();
- int idCounter;
- };
- class Account{
- public:
- int getAcctNum();
- int getType();
- string getOwner();
- Account(int, int, string, int, double);
- void changeBalance(double);
- private:
- int acctNum;
- int ownerNum;
- string owner;
- int type;
- double balance;
- };
- class AccountVector
- {
- public:
- vector<Account> accountList;
- AccountVector();
- void readIn();
- void AddAccount(string, float, int, double);
- };
- class Password
- {
- private:
- string passw;
- public:
- bool operator ==(const Password&) const;
- bool operator ==(const string&) const;
- Password();
- Password(string);
- bool changePass();
- };
- class Staff{
- public:
- string getName();
- bool authenticate(string pass);
- Staff(string, string, bool);
- bool admin;
- bool changePass();
- string staffOut();
- private:
- string name;
- Password password;
- };
- class StaffVector
- {
- public:
- vector<Staff> staffList;
- StaffVector();
- void addStaff(string, string, bool);
- void readIn();
- void writeOut();
- };
- class staffMenu{
- public:
- staffMenu(Staff);
- staffMenu(int);
- ClientVector addClient(ClientVector);
- StaffVector changePass(StaffVector);
- ClientVector changeInfo(ClientVector);
- AccountVector manageAccount(AccountVector);
- private:
- int selection;
- };
- AccountVector staffMenu::manageAccount(AccountVector acIN)
- {
- AccountVector accountList = acIN;
- ClientVector clientList;
- int accountChoice;
- int choice;
- cout<<"Whice account will be managed?";
- cin>>accountChoice;
- for(int i = 0; i < accountList.accountList.size();i++)
- {
- if(accountChoice == accountList.accountList[i].getAcctNum())
- {
- while(true)
- {
- cout<<"Manage accout "<<accountChoice<<" for "<<accountList.accountList[i].getOwner()<<"..."<<endl;
- cout<<"1) Deposit"<<endl;
- cout<<"2) Withdraw"<<endl;
- cout<<"3) Cancel"<<endl;
- cout<<"Please choose an option";
- cin>>choice;
- switch(choice)
- {
- case 1:
- double deposit;
- cout<<"Deposit Amount: ";
- cin>>deposit;
- if(cin.good())
- accountList.accountList[i].changeBalance(deposit);// += deposit;
- break;
- case 2:
- double withdrawal;
- cout<<"Withdrawal Amount: ";
- cin>>withdrawal;
- withdrawal = 0 - withdrawal;
- accountList.accountList[i].changeBalance(withdrawal);// += deposit;
- //do with withdrawal
- break;
- case 3:
- return accountList;
- }
- }
- }
- }
- }
- class Login
- {
- public:
- Login(StaffVector);
- string getName();
- bool changePass(string old1, string old2, string newpass);
- private:
- string password, name;
- bool admin;
- };
- void Account::changeBalance(double amount)
- {
- balance += amount;
- if(amount > balance)
- {balance -= 38;} //overdraft fee
- }
- class adminMenu{
- public:
- void displayBranchStaff();
- StaffVector addStaff(StaffVector);
- StaffVector deleteStaff(StaffVector);
- void accessStaffMenu(int);
- adminMenu();
- private:
- int selection;
- };
- Password::Password()
- {
- }
- Password::Password(string passIN)
- {
- passw = passIN;
- }
- adminMenu::adminMenu()
- {
- StaffVector listOfStaff;
- listOfStaff.readIn();
- int option = 0;
- while(true)
- {
- cout<<"========================================================"<<endl;
- cout<<" Teller Terminal System – System Administration "<<endl;
- cout<<"========================================================"<<endl;
- cout<<"1) Add a branch staff member"<<endl;
- cout<<"2) Delete a branch staff member"<<endl;
- cout<<"3) Display branch staff"<<endl;
- cout<<"4) Client and Account Management"<<endl;
- cout <<"5) Change password" << endl;
- cout<<"6) Exit"<<endl;
- cout<<endl;
- cout<<"Please choose an option:";
- cin>>option;
- switch(option)
- {
- case 1:
- {
- listOfStaff = addStaff(listOfStaff);
- break;
- }
- case 2:
- {
- listOfStaff = deleteStaff(listOfStaff);
- break;
- }
- case 3:
- {
- break;
- }
- case 4:
- {
- accessStaffMenu(4);
- break;
- }
- case 5:
- {
- accessStaffMenu(5);
- break;
- }
- case 6:
- {
- exit(0);
- }
- default:
- {
- cout<<"Invalid input, please try again\n";
- }
- }
- cout<<endl;
- }
- }
- void adminMenu::accessStaffMenu(int selection)
- {
- staffMenu adminAccess = staffMenu(selection);
- }
- StaffVector adminMenu::addStaff(StaffVector svIN)
- {
- cout<<"Add a staff member\n";
- StaffVector staffList = svIN;
- string nameEntry, passwordEntry;
- bool adminEntry;
- cout<<"User Name: ";
- // getline (cin,nameEntry);
- cin>>nameEntry;// .ignore();
- cout<<endl;
- cout<<"Password: ";
- // getline (cin,passwordEntry);
- cin>>passwordEntry;//.ignore();
- cout<<endl;
- cout<<"Role (1 - Administrator; 0 - Branch Staff): ";
- cin>>adminEntry;
- if((adminEntry == 0) || (adminEntry == 1))
- {
- Staff staffEntry = Staff(nameEntry,passwordEntry,adminEntry);
- staffList.staffList.push_back(staffEntry);
- }
- else
- {
- while((adminEntry != 0) && (adminEntry != 1))
- {
- cout<<"invalid staff type, please try again:";
- cin>>adminEntry;
- }
- Staff staffEntry = Staff(nameEntry,passwordEntry,adminEntry);
- staffList.staffList.push_back(staffEntry);
- }
- return staffList;
- }
- void adminMenu::displayBranchStaff()
- {
- StaffVector staffList;
- cout<<"There are "<<staffList.staffList.size()<<" users in the system."<<endl;
- // for(int i = 0; staffList.staffList.size(); i++)
- // {
- // cout<<
- //
- // }
- }
- StaffVector adminMenu::deleteStaff(StaffVector svIN)
- {
- int option;
- StaffVector listOfStaff = svIN;
- string userToDelete;
- cout<<"Delete a user - User Name: ";
- cin>>userToDelete;
- cout<<"1) Confirm\n";
- cout<<"2) Cancel\n";
- cin>>option;
- switch(option)
- {
- case 1:
- {
- bool nothere = true;
- for(int i = 0; i < listOfStaff.staffList.size(); i++)
- {
- if(userToDelete == listOfStaff.staffList[i].getName())
- {
- listOfStaff.staffList.erase(listOfStaff.staffList.begin()+i-1);
- cout<<"User "<<userToDelete<<" was deleted!\n";
- nothere = false;
- }
- }
- if(nothere)cout<<"Warning - User "<<userToDelete<<" is not in the system. No user is deleted!\n";
- break;
- }
- case 2:
- break;
- }
- return listOfStaff;
- }
- int main()
- {
- {
- //TEST STUFF
- // ClientVector clientList;
- // clientList.readIn();
- // AccountVector accountList;
- // accountList.readIn();
- StaffVector staffList;
- staffList.readIn();
- Login test = Login(staffList);
- // clientList = test.changeInfo(clientList);
- // for(int i = 0; i < clientList.clientList.size(); i++)
- // {
- // cout << clientList.clientList[i].getID() << endl;
- // }
- // ClientVector test = ClientVector();
- // for(int i = 0; i < test.clientList.size(); i++)
- // {
- // cout << test.clientList[i].getID() << endl;
- // }
- // cout << "now for accounts" << endl;
- // AccountVector test2 = AccountVector();
- // for(int j = 0; j < test2.accountList.size(); j++)
- // {
- // cout << test2.accountList[j].getAcctNum() << endl;
- // }
- // cout << "now for staff" << endl;
- // StaffVector test3 = StaffVector();
- // for(int k = 0; k < test3.staffList.size(); k++)
- // {
- // cout << test3.staffList[k].getName() << endl;
- // }
- }
- return 0;
- }
- bool Password::operator ==(const string &passwIN) const
- {
- return (passw == passwIN);
- }
- bool Password::changePass()
- {
- // string newPass;
- // cout <<"Please input current password: ";
- // cin>>newPass;
- }
- Login::Login(StaffVector svIN)
- {
- StaffVector staffList = svIN;
- string userName;
- int option = 0;
- string passwordTry;
- cout<<"========================================================"<<endl;
- cout<<" Welcome to the Auburn Branch of the Tiger Bank "<<endl;
- cout<<"========================================================"<<endl;
- cout<<"1)Login"<<endl;
- cout<<"2)Quit"<<endl;
- cout<<endl;
- cout<<"Please choose an option:";
- cin>>option;
- cout<<endl;
- switch(option)
- {
- case 1:
- cout<<"========================================================"<<endl;
- cout<<" Login to Access the Teller Terminal System "<<endl;
- cout<<"========================================================"<<endl;
- while(true)
- {
- cout<<endl;
- cout<<"UserName:";
- cin>>userName;
- cout<<"Password:";
- cin>>passwordTry;
- for(int i = 0; i < staffList.staffList.size(); i++)
- {
- cout << i << endl;
- if((userName == staffList.staffList[i].getName()) &&
- (staffList.staffList[i].authenticate(passwordTry)))
- {
- if(staffList.staffList[i].admin)
- {
- adminMenu aMenu;
- }
- else
- staffMenu sMenu = staffMenu(staffList.staffList[i]);
- }
- else
- {
- cout<<"invalid username or password, try again: ";
- }
- }
- }
- case 2:
- break;
- }
- }
- staffMenu::staffMenu(Staff loggedIn)
- {
- int option = 0;
- int manageOption = 0;
- while(true)
- {
- cout<<"========================================================"<<endl;
- cout<<" Teller Terminal System – Branch Staff "<<endl;
- cout<<"========================================================"<<endl;
- cout<<"1) Client and Account Management"<<endl;
- cout <<"2) Change password" << endl;
- cout<<"3) Exit"<<endl;
- cout<<endl;
- cout<<"Please choose an option:" ;
- cin >> option;
- switch(option)
- {
- case 1:
- {
- cout<<"========================================================"<<endl;
- cout<<" Teller Terminal System – Client and Account Management "<<endl;
- cout<<"========================================================"<<endl;
- ClientVector listOfClients;
- listOfClients.readIn();
- AccountVector listofAccts;
- listofAccts.readIn();
- bool loop = true;
- while(loop)
- {
- cout <<"1) Add a client"<<endl;
- cout<<"2) Add an account"<<endl;
- cout<<"3) Edit Client Information"<<endl;
- cout<<"4) Manage an account"<<endl;
- cout<<"5) Save Client and Account Information"<<endl;
- cout<<"6) Exit"<<endl;
- cout<<"Please choose an option: ";
- cin>>manageOption;
- switch(manageOption)
- {
- case 1:
- {
- listOfClients = addClient(listOfClients);
- break;
- }
- case 2:
- {
- cout<<"Temoporalily unavailable, sorry for the innconvience\n";
- break;
- }
- case 3:
- {
- listOfClients = changeInfo(listOfClients);
- break;
- }
- case 4:
- {
- listofAccts = manageAccount(listofAccts);
- break;
- }
- case 5:
- {
- listofAccts = manageAccount(listofAccts);
- break;
- }
- case 6:
- {
- loop = false;
- break;
- }
- }
- }
- break;
- }
- case 2:
- {
- loggedIn.changePass();
- break;
- }
- case 3:
- {
- exit(0);
- }
- default:
- {
- cout<<"Invalid selection.\n";
- }
- }
- }
- }
- ClientVector staffMenu::addClient(ClientVector cvIN)//(string name, string address, float ssn, string employer, float income)
- {
- ClientVector clientList = cvIN;
- string nameEntry;
- string addressEntry;
- string employerEntry;
- string ssnEntry;
- double incomeEntry;
- cout<<"A new client will be added:"<<endl;
- cout<<"Client name:";
- getline(cin,nameEntry);
- cin.ignore();
- cout<<"Address:";
- getline(cin,addressEntry);
- cin.ignore();
- cout<<"Social security number:";
- getline(cin,ssnEntry);
- cin.ignore();
- cout<<"Employer:";
- getline(cin,employerEntry);
- cin.ignore();
- cout<<"Annual income:";
- cin>>incomeEntry;
- cout<<endl;
- cout<<"A new client was added!";
- cout<<endl;
- Client clientEntry = Client(clientList.idCounter,nameEntry, addressEntry, ssnEntry, employerEntry, incomeEntry);
- clientList.clientList.push_back(clientEntry);
- clientList.idCounter++;
- return clientList;
- }
- ClientVector staffMenu::changeInfo(ClientVector cvIN)
- {
- string nameEntry;
- string addressEntry;
- string employerEntry;
- string ssnEntry;
- double incomeEntry;
- int option;
- ClientVector clientList = cvIN;
- string clientName;
- cout<<"Choose a client: ";
- getline (cin,clientName);
- // cout<<clientName << clientList.clientList.size();
- for(int i = 0; i < clientList.clientList.size(); i++)
- {
- cout<<endl;
- cout<<"Checking for client "<<endl;; //<< clientList.clientList[0].getName() << endl;
- if((clientName == clientList.clientList[i].getName()))
- {
- cout<<"Display "<<clientName<<"\'s information:"<<endl;
- cout<<"Address: "<<clientList.clientList[i].getAddress()<<endl;
- cout<<"Social Security Number: "<<clientList.clientList[i].getSSN()<<endl;
- cout<<"Employer: "<<clientList.clientList[i].getEmployer()<<endl;
- cout<<"Annual Income: "<<clientList.clientList[i].getIncome()<<endl;
- cout<<"Client "<<clientName<<"\'s information will be updated..."<<endl;
- cout<<"1) Confirm"<<endl;
- cout<<"2) Cancel" <<endl;
- while(true)
- {
- cout<<"Please choose an option (option 1 is confirm information, option 2 is cancel and go back to the menu): "<<endl;
- cin>>option;
- // cin.ignore();
- switch(option){
- case 1:
- cout<< "Confirm client information: \n";
- cout<<"Address: ";
- getline(cin,addressEntry);
- cin.ignore();
- cout<<endl;
- cout<<"Social security number: ";
- getline(cin,ssnEntry);
- cin.ignore();
- cout<<endl;
- cout<<"Employer: ";
- getline(cin,employerEntry);
- cin.ignore();
- cout<<"Annual income: ";
- cin>>incomeEntry;
- cout<<endl;
- cout << "address " << addressEntry << endl;
- cout << "SSN " << ssnEntry << endl;
- cout << "employer " <<employerEntry << endl;
- cout << "income " << incomeEntry << endl;
- clientList.clientList[i].setAddress(addressEntry);
- clientList.clientList[i].setSSN(ssnEntry);
- clientList.clientList[i].setEmployer(employerEntry);
- clientList.clientList[i].setIncome(incomeEntry);
- break;
- case 2:
- return clientList;
- default:
- cout<<"Invalid Choice"<<endl;
- }
- }
- }
- }
- cout<<"User Name: "<<clientName<<" is not on file"<<endl;
- return clientList;
- }
- Account::Account(int acctNumIN, int ownerNumIN, string ownerIN, int typeIN, double balanceIN)
- {
- acctNum = acctNumIN;
- ownerNum = ownerNumIN;
- owner = ownerIN;
- type = typeIN;
- balance = balanceIN;
- }
- int Account::getAcctNum()
- {
- return acctNum;
- }
- string Account::getOwner()
- {
- return owner;
- }
- AccountVector::AccountVector()
- {
- }
- void AccountVector::readIn()
- {
- ifstream file;
- file.open("account-info.txt");
- if(file.fail())
- {
- exit(1);
- }
- char charAcctNum[20], charOwnerNum[20], inOwner[20], charType[5], charBalance[20];
- int inAcctNum, inOwnerNum, inType;
- double inBalance;
- file.ignore(50, '\r');
- while (!file.eof())
- {
- file.getline(charAcctNum, 20, '\t');
- inAcctNum = atoi(charAcctNum);
- file.getline(charOwnerNum, 20, '\t');
- inOwnerNum = atoi(charOwnerNum);
- file.getline(inOwner, 20, '\t');
- file.getline(charType, 5, '\t');
- inType = atoi(charType);
- file.getline(charBalance, 20, '\r');
- inBalance = atof(charBalance);
- Account accountEntry = Account(inAcctNum, inOwnerNum, inOwner, inType, inBalance);
- accountList.push_back(accountEntry);
- }
- cout << "remember to error check against pre-existing account numbers \n";
- file.close();
- }
- void ClientVector::readIn()
- {
- ifstream file;
- file.open("client-info.txt");
- if(file.fail())
- {
- exit(1);
- }
- char charClientID[12], inName[20], inSsn[12], inEmployer[50], charIncome[16], inAddress[50];
- double inIncome;
- int inClientID;
- file.ignore(50, '\r');
- while (!file.eof())
- {
- file.getline(charClientID, 50, '\t');
- inClientID = atoi(charClientID);
- file.getline(inName, 50, '\t');
- file.getline(inAddress, 50, '\t');
- file.getline(inSsn, 12, '\t');
- file.getline(inEmployer, 50, '\t');
- file.getline(charIncome, 15, '\r');
- inIncome = atof(charIncome);
- Client clientEntry = Client(inClientID, inName, inAddress, inSsn, inEmployer, inIncome);
- clientList.push_back(clientEntry);
- idCounter++;
- }
- cout << "remember to error check against pre-existing Client names \n";
- file.close();
- }
- ClientVector::ClientVector()
- {
- idCounter = 1;
- }
- void Client::addAccount(float accountNum, string accType, float balance)
- {
- }
- int Client::getID()
- {
- return clientID;
- }
- string Client::getAddress()
- {
- return address;
- }
- void Client::setAddress(string newAddress)
- {
- address = newAddress;
- }
- void Client::setEmployer(string newEmployer)
- {
- employer = newEmployer;
- }
- void Client::setSSN(string newSSN)
- {
- ssn = newSSN;
- }
- void Client::setIncome(double newIncome)
- {
- income = newIncome;
- }
- string Client::getEmployer()
- {
- return employer;
- }
- string Client::getName()
- {
- return name;
- }
- string Client::getSSN()
- {
- return ssn;
- }
- double Client::getIncome()
- {
- return income;
- }
- Client::Client(int newID, string newName, string newAddress, string newSsn, string newEmployer, double newIncome)
- {
- clientID = newID;
- name = newName;
- address = newAddress;
- ssn = newSsn;
- employer = newEmployer;
- income = newIncome;
- }
- bool Staff::authenticate(string passIN)
- {
- return(password == passIN);
- }
- bool Staff::changePass()
- {
- string currentPass, newPass1, newPass2;
- cout <<"Please input current password: ";
- cin>>currentPass;
- cout<<endl;
- if(authenticate(currentPass))
- {
- cout <<"Please input new password: ";
- cin>>newPass1;
- cout<<endl;
- cout <<"Please input new password again: ";
- cin>>newPass2;
- }
- return true;
- }
- string Staff::staffOut()
- {
- string out1, out2, out3, out4, out;
- out1 = name;
- out2= '\t';
- out3 = admin;
- out4='\n';
- out = out1+out2+out3+out4;
- return out;
- }
- Staff::Staff(string nameIN, string passwordIN, bool adminIN)
- {
- name = nameIN;
- password = passwordIN;
- admin = adminIN;
- }
- string Staff::getName()
- {
- return name;
- }
- StaffVector::StaffVector()
- {
- }
- void StaffVector::readIn()
- {
- ifstream file;
- file.open("staff.txt");
- if(file.fail())
- {
- exit(1);
- }
- char inName[20], inPassword[28], charAdmin[2];
- int inAdmin;
- file.ignore(50, '\r');
- while (!file.eof())
- {
- file.getline(inName, 19, '\t');
- file.getline(inPassword, 27, '\t');
- file.getline(charAdmin, 2, '\r');
- inAdmin = atoi(charAdmin);
- Staff staffEntry = Staff(inName, inPassword, inAdmin);
- staffList.push_back(staffEntry);
- }
- cout << "remember to error check against pre-existing staff \n";
- file.close();
- }
- staffMenu::staffMenu(int option)
- {
- switch(option)
- {
- case 4:
- {
- cout<<"========================================================"<<endl;
- cout<<" Teller Terminal System – Client and Account Management "<<endl;
- cout<<"========================================================"<<endl;
- ClientVector listOfClients;
- listOfClients.readIn();
- AccountVector listofAccts;
- listofAccts.readIn();
- int manageOption;
- bool loop = true;
- while(loop)
- {
- cout <<"1) Add a client"<<endl;
- cout<<"2) Add an account"<<endl;
- cout<<"3) Edit Client Information"<<endl;
- cout<<"4) Manage an account"<<endl;
- cout<<"5) Save Client and Account Information"<<endl;
- cout<<"6) Exit"<<endl;
- cout<<"Please choose an option: ";
- cin>>manageOption;
- switch(manageOption)
- {
- case 1:
- {
- listOfClients = addClient(listOfClients);
- break;
- }
- case 2:
- {
- cout<<"Temoporalily unavailable, sorry for the innconvience\n";
- break;
- }
- case 3:
- {
- listOfClients = changeInfo(listOfClients);
- break;
- }
- case 4:
- {
- listofAccts = manageAccount(listofAccts);
- break;
- }
- case 5:
- {
- listofAccts = manageAccount(listofAccts);
- break;
- }
- case 6:
- {
- loop = false;
- break;
- }
- }
- }
- }
- case 5:
- {
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement