Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Entity
- {
- public:
- void SetDeposit(int val)
- {
- CheckBalance += val;
- }
- void SetWithdraw(int val)
- {
- CheckBalance -= val;
- }
- int GetCheckBalance()
- {
- return CheckBalance;
- }
- void SetCheckBalance(int val)
- {
- CheckBalance = val;
- }
- string GetEntityName()
- {
- return EntityName;
- }
- string GetEntityPassword()
- {
- return EntityPassword;
- }
- void SetEntityName(string val)
- {
- EntityName = val;
- }
- protected:
- int CheckBalance;
- string EntityName;
- string EntityPassword;
- };
- class Customer: public Entity
- {
- public:
- Customer(int bal, string name, string password);
- void Talk()
- {
- cout << "My name is " + GetEntityName() << endl;
- }
- };
- Customer::Customer(int bal, string name, string password)
- {
- CheckBalance = bal;
- EntityName = name;
- EntityPassword = password;
- }
- class Banker
- {
- };
- int main()
- {
- int loggedIn = 0;
- bool logInFailed = false;
- int i = 0;
- int x = 0;
- string input1 = "";
- Customer *customers[10];
- int input;
- for(i = 0; i < 20; i++)
- {
- customers[i] = new Customer(0, "", "");
- }
- customers[0] = new Customer(0, "Test", "Test");
- while(true)
- {
- while(loggedIn == 0)
- {
- logInFailed = false;
- cout << "Register Or Login" << endl;
- cin >> input1;
- if(input1 == "login")
- {
- cout << "Enter your username." << endl;
- string userAnswer = "";
- cin >> userAnswer;
- for(i = 0; i < 10; i++)
- {
- if(userAnswer == customers[i] -> GetEntityName())
- {
- cout << "User name found." << endl;
- cout << "Enter your password" << endl;
- string userPass = "";
- cin >> userPass;
- for(i = 0; i < 10; i++)
- {
- if(userPass == customers[i] -> GetEntityPassword() && loggedIn == 0)
- {
- x = i;
- cout << "User and password were correct." << endl;
- loggedIn = 1;
- }
- }
- for(i = 0; i < 10; i++)
- {
- if(userPass != customers[i] -> GetEntityPassword() && loggedIn == 0 && logInFailed == false)
- {
- cout << "Incorrect password. " << endl;
- logInFailed = true;
- }
- }
- }
- }
- for(i = 0; i < 10; i++)
- {
- if(userAnswer != customers[i] -> GetEntityName() && loggedIn == 0 && logInFailed == false)
- {
- cout << "Username was not found.";
- logInFailed = true;
- }
- }
- }
- else if(input1 == "register")
- {
- cout << "Please enter your desired username." << endl;
- string newUser = "";
- cin >> newUser;
- cout << "Please enter your desired password" << endl;
- string newPass = "";
- cin >> newPass;
- customers[x] = new Customer(0, newUser, newPass);
- cout << "You registered user: " << newUser << " with the password: " << newPass << endl;
- x++;
- }
- }
- while(loggedIn == 1)
- {
- cout << "Welcome to the Royal Bank." << endl;
- cout << customers[x] -> GetEntityName() << " would you like to 1.) Deposit, 2.) Withdraw or 3.) CheckBalance" << endl;
- cin >> input;
- int input2;
- int totalBalance = 0;
- if(input == 1)
- {
- cout << "Baird, you have chosen to Deposit. How much money would you like to deposit? " << endl;
- cin >> input2;
- customers[x] -> SetDeposit(input2);
- totalBalance = customers[x] -> GetCheckBalance();
- cout << "You now have $ " << totalBalance << " in your account now." << endl;
- }
- int input3;
- int NewTotalBalance = 0;
- if(input == 2)
- {
- cout << "Baird, you have now chosen to Withdraw. How much money would you like to withdraw?" << endl;
- cin >> input3;
- customers[x] -> SetWithdraw(input3);
- NewTotalBalance = customers[x] -> GetCheckBalance();
- cout << "You now have $ " << NewTotalBalance << " in your account now." << endl;
- }
- int Balance = 0;
- if(input == 3)
- {
- cout << "Baird, you have now chosen to check how much money is in your bank account. " << endl;
- Balance = customers[x] ->GetCheckBalance();
- cout << "There is $ " << Balance << " in your account." << endl;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement