Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- static int lastID = 0;
- class Account;
- class Client ;
- class Bank;
- int main() {
- cin.get();
- cin.get();
- return 0;
- }
- class Client {
- private:
- string name;
- string lastName;
- string password;
- int ID;
- string mail;
- public:
- Client() {}
- Client(string name, string lastName, string password, string mail)
- {
- this->ID = lastID;
- this->name = name;
- this->lastName = lastName;
- this->mail = mail;
- this->password = password;
- }
- Client(vector<Account>clientAccounts, string name, string lastName, string password, int ID, string mail)
- {
- this->ID = ID;
- this->name = name;
- this->lastName = lastName;
- this->mail = mail;
- this->password = password;
- }
- string getName() { return name; }
- string getLastName() { return lastName; }
- int getID() { return ID; }
- string getMail() { return mail; }
- string getPassword() { return password; }
- };
- class Account {
- private:
- Client client;
- string walletName;
- int ID;
- string accNumber;
- float GEL;
- float USD;
- public:
- Account(){}
- Account(string walletName, int ID, string accNumber, float GEL, float USD)
- {
- this->walletName = walletName;
- this->ID = client.getID();
- this->accNumber = accNumber;
- this->GEL = GEL;
- this->USD = USD;
- }
- string getAccountName() { return walletName; }
- int getID() { return ID; }
- string getAccountNumber(){ return accNumber; }
- float getUSD() { return USD; }
- float getGEL() { return GEL; }
- void printWalletInfo() {
- cout << "Name of your wallet " << getAccountName() << endl;
- cout << "Wallet Unique Address " << getAccountNumber() << endl;
- cout << "GEL: " << getGEL() << endl;
- cout << "USD: " << getUSD() << endl;
- }
- void setUSD(float USD) { this->USD = USD; }
- void setGEL(float GEL) { this->GEL = GEL; }
- };
- class Bank {
- private:
- string bankName;
- vector<Account*> aList;
- vector<Client*> cList;
- float BankMoney;
- public:
- Bank(string bankName, vector<Account*>aList, vector<Client*>cList, float BankMoney)
- {
- this->bankName = bankName;
- this->aList = aList;
- this->cList = cList;
- this->BankMoney = BankMoney;
- }
- void LoginPage() {
- cout << "1) Login" << endl;
- cout << "2) Register" << endl;
- int choice;
- switch (choice) {
- case 1:
- LoginToBank();
- break;
- case 2:
- CreateNewClient();
- break;
- default:
- break;
- }
- }
- void DisplayUserWallets(vector<Account*> Wallets) {
- for (auto wallet : Wallets) {
- wallet->printWalletInfo();
- cout << endl << "=============================================" << endl;
- }
- }
- void TransferMoney(Client* instance, vector<Account*> myWallets) {
- string targetUNumber;
- Account* target;
- Account* prefferedWallet;
- string walletID;
- bool transferring = true;
- while (transferring) {
- cout << "Enter unique number of client's account: ";
- cin >> targetUNumber;
- for (Account* wallet : aList) {
- if (wallet->getAccountNumber() == targetUNumber) {
- target = wallet;
- }
- }
- if (target == NULL) {
- cout << "Incorrect unique address." << endl;
- }
- else {
- transferring = false;
- }
- }
- cout << "Choose which wallet do you want to transfer your money from." << endl;
- for (auto item : myWallets) {
- cout << item->getAccountName() << endl;
- }
- cin >> walletID;
- for (auto item : myWallets)
- {
- if (item->getAccountName() == walletID) {
- prefferedWallet = item;
- }
- }
- cout << "Enter which currency you would like to transfer: ";
- string currency;
- cin >> currency;
- }
- void LoadUserUI(Client* instance) {
- system("cls");
- vector<Account*> myWallets = GetUserWallets(instance);
- cout << "Welcome " << instance->getName() << " " << instance->getLastName() << "!" << endl;
- cout << "1) Check your wallets " << endl;
- cout << "2) Make a transaction to other user " << endl;
- cout << "3) Deposit money to your wallet " << endl;
- cout << "4) Withdraw money from your account " << endl;
- cout << "5) Log out" << endl;
- int choice;
- cin >> choice;
- switch (choice)
- {
- case 1:
- DisplayUserWallets(myWallets);
- break;
- case 2:
- TransferMoney(instance, myWallets);
- break;
- case 3:
- break;
- case 4:
- break;
- default:
- break;
- }
- }
- void LoginToBank() {
- string email;
- string password;
- Client* instance;
- bool login = true;
- while(login){
- cout << "Enter your eMail: ";
- cin >> email;
- cout << "Enter your password:";
- cin >> password;
- instance = VerifyUserInDatabase(email, password);
- if (instance == NULL) {
- login = false;
- }
- }
- LoadUserUI(instance);
- }
- vector<Account*> GetUserWallets(Client* instance) {
- vector<Account*>userWallets;
- for (auto* item : aList) {
- if (item->getID() == instance->getID())
- {
- userWallets.push_back(item);
- }
- }
- return userWallets;
- }
- Client* VerifyUserInDatabase(string email, string password) {
- for (auto item : cList) {
- if (item->getMail() == email) {
- if (item->getPassword() == password) {
- return item;
- }
- }
- else {
- cout << "Incorrect user details try again." << endl;
- return nullptr;
- }
- }
- }
- void CreateNewClient() {
- system("cls");
- string clientsName;
- string clientsLastName;
- string email;
- string password;
- cout << "Enter your name: ";
- cin >> clientsName;
- cout << "Enter your lastName: ";
- cin >> clientsLastName;
- cout << "Enter your email: ";
- cin >> email;
- cout << "Enter your password: ";
- cin >> password;
- system("cls");
- Client* NewClient = new Client(clientsName, clientsLastName, password, email);
- cList.push_back(NewClient);
- cout << "You have successfully registered to " << bankName << endl;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement