Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6. static int lastID = 0;
  7. class Account;
  8.  
  9. class Client ;
  10.  
  11. class Bank;
  12.  
  13.  
  14. int main() {
  15.  
  16. cin.get();
  17. cin.get();
  18. return 0;
  19. }
  20.  
  21.  
  22. class Client {
  23. private:
  24. string name;
  25. string lastName;
  26. string password;
  27. int ID;
  28. string mail;
  29. public:
  30. Client() {}
  31. Client(string name, string lastName, string password, string mail)
  32. {
  33. this->ID = lastID;
  34. this->name = name;
  35. this->lastName = lastName;
  36. this->mail = mail;
  37. this->password = password;
  38. }
  39. Client(vector<Account>clientAccounts, string name, string lastName, string password, int ID, string mail)
  40. {
  41. this->ID = ID;
  42. this->name = name;
  43. this->lastName = lastName;
  44. this->mail = mail;
  45. this->password = password;
  46. }
  47.  
  48. string getName() { return name; }
  49. string getLastName() { return lastName; }
  50. int getID() { return ID; }
  51. string getMail() { return mail; }
  52. string getPassword() { return password; }
  53. };
  54.  
  55. class Account {
  56. private:
  57. Client client;
  58. string walletName;
  59. int ID;
  60. string accNumber;
  61. float GEL;
  62. float USD;
  63. public:
  64. Account(){}
  65. Account(string walletName, int ID, string accNumber, float GEL, float USD)
  66. {
  67. this->walletName = walletName;
  68. this->ID = client.getID();
  69. this->accNumber = accNumber;
  70. this->GEL = GEL;
  71. this->USD = USD;
  72. }
  73. string getAccountName() { return walletName; }
  74. int getID() { return ID; }
  75. string getAccountNumber(){ return accNumber; }
  76. float getUSD() { return USD; }
  77. float getGEL() { return GEL; }
  78.  
  79. void printWalletInfo() {
  80. cout << "Name of your wallet " << getAccountName() << endl;
  81. cout << "Wallet Unique Address " << getAccountNumber() << endl;
  82. cout << "GEL: " << getGEL() << endl;
  83. cout << "USD: " << getUSD() << endl;
  84. }
  85.  
  86. void setUSD(float USD) { this->USD = USD; }
  87. void setGEL(float GEL) { this->GEL = GEL; }
  88. };
  89.  
  90. class Bank {
  91. private:
  92. string bankName;
  93. vector<Account*> aList;
  94. vector<Client*> cList;
  95. float BankMoney;
  96. public:
  97. Bank(string bankName, vector<Account*>aList, vector<Client*>cList, float BankMoney)
  98. {
  99. this->bankName = bankName;
  100. this->aList = aList;
  101. this->cList = cList;
  102. this->BankMoney = BankMoney;
  103. }
  104.  
  105. void LoginPage() {
  106. cout << "1) Login" << endl;
  107. cout << "2) Register" << endl;
  108. int choice;
  109. switch (choice) {
  110. case 1:
  111. LoginToBank();
  112. break;
  113. case 2:
  114. CreateNewClient();
  115. break;
  116. default:
  117. break;
  118. }
  119. }
  120.  
  121. void DisplayUserWallets(vector<Account*> Wallets) {
  122. for (auto wallet : Wallets) {
  123. wallet->printWalletInfo();
  124. cout << endl << "=============================================" << endl;
  125. }
  126. }
  127.  
  128. void TransferMoney(Client* instance, vector<Account*> myWallets) {
  129. string targetUNumber;
  130. Account* target;
  131. Account* prefferedWallet;
  132. string walletID;
  133.  
  134. bool transferring = true;
  135. while (transferring) {
  136. cout << "Enter unique number of client's account: ";
  137. cin >> targetUNumber;
  138. for (Account* wallet : aList) {
  139. if (wallet->getAccountNumber() == targetUNumber) {
  140. target = wallet;
  141. }
  142. }
  143. if (target == NULL) {
  144. cout << "Incorrect unique address." << endl;
  145. }
  146. else {
  147. transferring = false;
  148. }
  149. }
  150. cout << "Choose which wallet do you want to transfer your money from." << endl;
  151. for (auto item : myWallets) {
  152. cout << item->getAccountName() << endl;
  153. }
  154.  
  155. cin >> walletID;
  156. for (auto item : myWallets)
  157. {
  158. if (item->getAccountName() == walletID) {
  159. prefferedWallet = item;
  160. }
  161. }
  162.  
  163. cout << "Enter which currency you would like to transfer: ";
  164. string currency;
  165. cin >> currency;
  166.  
  167. }
  168.  
  169. void LoadUserUI(Client* instance) {
  170. system("cls");
  171. vector<Account*> myWallets = GetUserWallets(instance);
  172. cout << "Welcome " << instance->getName() << " " << instance->getLastName() << "!" << endl;
  173. cout << "1) Check your wallets " << endl;
  174. cout << "2) Make a transaction to other user " << endl;
  175. cout << "3) Deposit money to your wallet " << endl;
  176. cout << "4) Withdraw money from your account " << endl;
  177. cout << "5) Log out" << endl;
  178.  
  179. int choice;
  180. cin >> choice;
  181. switch (choice)
  182. {
  183. case 1:
  184. DisplayUserWallets(myWallets);
  185. break;
  186. case 2:
  187. TransferMoney(instance, myWallets);
  188. break;
  189. case 3:
  190. break;
  191. case 4:
  192. break;
  193. default:
  194. break;
  195. }
  196. }
  197.  
  198. void LoginToBank() {
  199. string email;
  200. string password;
  201. Client* instance;
  202. bool login = true;
  203. while(login){
  204. cout << "Enter your eMail: ";
  205. cin >> email;
  206. cout << "Enter your password:";
  207. cin >> password;
  208.  
  209. instance = VerifyUserInDatabase(email, password);
  210. if (instance == NULL) {
  211. login = false;
  212. }
  213. }
  214. LoadUserUI(instance);
  215. }
  216.  
  217. vector<Account*> GetUserWallets(Client* instance) {
  218. vector<Account*>userWallets;
  219. for (auto* item : aList) {
  220. if (item->getID() == instance->getID())
  221. {
  222. userWallets.push_back(item);
  223. }
  224. }
  225. return userWallets;
  226. }
  227.  
  228. Client* VerifyUserInDatabase(string email, string password) {
  229. for (auto item : cList) {
  230. if (item->getMail() == email) {
  231. if (item->getPassword() == password) {
  232. return item;
  233. }
  234. }
  235. else {
  236.  
  237. cout << "Incorrect user details try again." << endl;
  238. return nullptr;
  239. }
  240. }
  241. }
  242.  
  243. void CreateNewClient() {
  244. system("cls");
  245. string clientsName;
  246. string clientsLastName;
  247. string email;
  248. string password;
  249. cout << "Enter your name: ";
  250. cin >> clientsName;
  251. cout << "Enter your lastName: ";
  252. cin >> clientsLastName;
  253. cout << "Enter your email: ";
  254. cin >> email;
  255. cout << "Enter your password: ";
  256. cin >> password;
  257. system("cls");
  258. Client* NewClient = new Client(clientsName, clientsLastName, password, email);
  259. cList.push_back(NewClient);
  260. cout << "You have successfully registered to " << bankName << endl;
  261. }
  262.  
  263. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement