Advertisement
Guest User

Untitled

a guest
Aug 31st, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Entity
  6. {
  7. public:
  8.  
  9. void SetDeposit(int val)
  10. {
  11. CheckBalance += val;
  12. }
  13.  
  14. void SetWithdraw(int val)
  15. {
  16. CheckBalance -= val;
  17. }
  18.  
  19. int GetCheckBalance()
  20. {
  21. return CheckBalance;
  22. }
  23.  
  24. void SetCheckBalance(int val)
  25. {
  26. CheckBalance = val;
  27. }
  28.  
  29. string GetEntityName()
  30. {
  31. return EntityName;
  32. }
  33.  
  34. string GetEntityPassword()
  35. {
  36. return EntityPassword;
  37. }
  38.  
  39. void SetEntityName(string val)
  40. {
  41. EntityName = val;
  42. }
  43.  
  44. protected:
  45.  
  46. int CheckBalance;
  47. string EntityName;
  48. string EntityPassword;
  49.  
  50. };
  51.  
  52.  
  53. class Customer: public Entity
  54. {
  55. public:
  56.  
  57. Customer(int bal, string name, string password);
  58.  
  59. void Talk()
  60. {
  61. cout << "My name is " + GetEntityName() << endl;
  62. }
  63. };
  64.  
  65. Customer::Customer(int bal, string name, string password)
  66. {
  67. CheckBalance = bal;
  68. EntityName = name;
  69. EntityPassword = password;
  70. }
  71.  
  72. class Banker
  73. {
  74.  
  75.  
  76.  
  77. };
  78.  
  79.  
  80. int main()
  81. {
  82. int loggedIn = 0;
  83. bool logInFailed = false;
  84. int i = 0;
  85. int x = 0;
  86. string input1 = "";
  87.  
  88. Customer *customers[10];
  89.  
  90. int input;
  91.  
  92. for(i = 0; i < 20; i++)
  93. {
  94. customers[i] = new Customer(0, "", "");
  95. }
  96.  
  97. customers[0] = new Customer(0, "Test", "Test");
  98.  
  99. while(true)
  100. {
  101. while(loggedIn == 0)
  102. {
  103. logInFailed = false;
  104. cout << "Register Or Login" << endl;
  105. cin >> input1;
  106. if(input1 == "login")
  107. {
  108. cout << "Enter your username." << endl;
  109. string userAnswer = "";
  110. cin >> userAnswer;
  111.  
  112. for(i = 0; i < 10; i++)
  113. {
  114. if(userAnswer == customers[i] -> GetEntityName())
  115. {
  116. cout << "User name found." << endl;
  117. cout << "Enter your password" << endl;
  118. string userPass = "";
  119. cin >> userPass;
  120. for(i = 0; i < 10; i++)
  121. {
  122. if(userPass == customers[i] -> GetEntityPassword() && loggedIn == 0)
  123. {
  124. x = i;
  125. cout << "User and password were correct." << endl;
  126. loggedIn = 1;
  127. }
  128. }
  129.  
  130. for(i = 0; i < 10; i++)
  131. {
  132. if(userPass != customers[i] -> GetEntityPassword() && loggedIn == 0 && logInFailed == false)
  133. {
  134. cout << "Incorrect password. " << endl;
  135. logInFailed = true;
  136. }
  137. }
  138.  
  139.  
  140. }
  141.  
  142. }
  143.  
  144. for(i = 0; i < 10; i++)
  145. {
  146. if(userAnswer != customers[i] -> GetEntityName() && loggedIn == 0 && logInFailed == false)
  147. {
  148. cout << "Username was not found.";
  149. logInFailed = true;
  150. }
  151. }
  152. }
  153. else if(input1 == "register")
  154. {
  155. cout << "Please enter your desired username." << endl;
  156. string newUser = "";
  157. cin >> newUser;
  158. cout << "Please enter your desired password" << endl;
  159. string newPass = "";
  160. cin >> newPass;
  161. customers[x] = new Customer(0, newUser, newPass);
  162. cout << "You registered user: " << newUser << " with the password: " << newPass << endl;
  163. x++;
  164.  
  165. }
  166. }
  167.  
  168. while(loggedIn == 1)
  169. {
  170. cout << "Welcome to the Royal Bank." << endl;
  171. cout << customers[x] -> GetEntityName() << " would you like to 1.) Deposit, 2.) Withdraw or 3.) CheckBalance" << endl;
  172. cin >> input;
  173.  
  174. int input2;
  175. int totalBalance = 0;
  176. if(input == 1)
  177. {
  178. cout << "Baird, you have chosen to Deposit. How much money would you like to deposit? " << endl;
  179. cin >> input2;
  180. customers[x] -> SetDeposit(input2);
  181. totalBalance = customers[x] -> GetCheckBalance();
  182. cout << "You now have $ " << totalBalance << " in your account now." << endl;
  183. }
  184.  
  185. int input3;
  186. int NewTotalBalance = 0;
  187. if(input == 2)
  188. {
  189. cout << "Baird, you have now chosen to Withdraw. How much money would you like to withdraw?" << endl;
  190. cin >> input3;
  191. customers[x] -> SetWithdraw(input3);
  192. NewTotalBalance = customers[x] -> GetCheckBalance();
  193. cout << "You now have $ " << NewTotalBalance << " in your account now." << endl;
  194. }
  195.  
  196. int Balance = 0;
  197. if(input == 3)
  198. {
  199. cout << "Baird, you have now chosen to check how much money is in your bank account. " << endl;
  200. Balance = customers[x] ->GetCheckBalance();
  201. cout << "There is $ " << Balance << " in your account." << endl;
  202.  
  203. }
  204. }
  205. }
  206.  
  207. return 0;
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement