Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2019
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <fstream>
  5. #include "windows.h"
  6.  
  7.  
  8.  
  9. using namespace std;
  10.  
  11. // Function timer in seconds
  12. void timer(int sec)
  13. {
  14. Sleep(sec*1000);
  15. }
  16.  
  17. //Save function
  18. void saveFunction(ofstream save, string site, string url, string username, string password)
  19. {
  20. save << site << endl;
  21. save << url << endl;
  22. save << username << endl;
  23. save << password << endl;
  24.  
  25. }
  26. //Load Function
  27. // Main program
  28. int main()
  29. {
  30.  
  31. int userAction; // Variable used to select an option
  32. string siteNameVar("site"), urlVar("url"), userNameVar("username"), passwordVar("pass") ;
  33. char sureVerification;
  34.  
  35. vector<string> siteName(0); // Vectors containing respectively : "The sites names"
  36. vector<string> url(0); // Vectors containing respectively : "The sites urls"
  37. vector<string> userName(0); // Vectors containing respectively : "The usernames"
  38. vector<string> password(0); // Vectors containing respectively : "The passwords"
  39.  
  40. ofstream Save("Account Manager/Save.txt"); //Trying to open the save file
  41.  
  42. if(Save) //Testing
  43. {
  44. //Ok it's working
  45. }
  46. else
  47. {
  48. cout << "ERROR. The file it is impossible to open the file" << endl; //Shit!
  49. }
  50.  
  51.  
  52. cout << "What will you do?" << endl;
  53.  
  54. cout << "1. Add a website account" << endl
  55. << "2. Connect to an existing account" << endl
  56. << "3. Delete an account"<< endl
  57. << "4. See all the existing accounts" << endl;
  58.  
  59.  
  60. cin >> userAction; // This is where the user enter his choice
  61.  
  62. switch (userAction){
  63. case 1: // Add a new element in the vectors
  64. system("cls");
  65.  
  66. //Adding elements sequence
  67. //Site Name
  68. do{
  69. cout << "Enter the website name" <<endl;
  70. cin >> siteNameVar;
  71. cout << "Are you sure? 1: Yes Anything Else: False" <<endl;
  72. cin >> sureVerification;
  73.  
  74. system("cls");
  75. }
  76.  
  77. while(sureVerification != '1');
  78. system("cls");
  79. siteName.push_back(siteNameVar);
  80.  
  81.  
  82.  
  83. //Site's Url
  84. do{
  85. cout << "Enter the site's login page url" << endl;
  86. cin >> urlVar;
  87. cout << "Are you sure? 1 = yes | Anything else = no" << endl;
  88. cin >> sureVerification;
  89. system("cls");
  90. }
  91.  
  92. while(sureVerification != '1');
  93. system("cls");
  94. url.push_back(urlVar);
  95.  
  96. // Username
  97. do{
  98. cout << "Enter your account's username" << endl;
  99. cin >> userNameVar;
  100. cout << "Are you sure? 1 = yes | Anything else = no" << endl;
  101. cin >> sureVerification;
  102. system("cls");
  103. }
  104.  
  105. while(sureVerification != '1');
  106. system("cls");
  107. userName.push_back(userNameVar);
  108.  
  109. // Password
  110. do{
  111. cout << "Enter your account's password" << endl;
  112. cin >> passwordVar;
  113. cout << "Are you sure? 1 = yes | Anything else = no" << endl;
  114. cin >> sureVerification;
  115. system("cls");
  116.  
  117. }
  118.  
  119. while(sureVerification != '1');
  120. system("cls");
  121. password.push_back(passwordVar);
  122.  
  123. //Display Everything
  124.  
  125. cout << "So the site's name is :" << siteName.back() << endl
  126. << "The login page url is :" << url.back() << endl
  127. << "Your account's username is :" << userName.back() << endl
  128. << "And your password is :" << password.back() << endl;
  129.  
  130. cout << endl << "Wait 5 seconds " << endl;
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138. //Where all the values are saved in vectors
  139.  
  140. saveFunction(Save, siteName, url, userName, password);
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147. // I need to add a save function
  148.  
  149.  
  150. //Get back to the main()
  151. timer(5);
  152.  
  153. system("cls");
  154. return main();
  155.  
  156.  
  157. case 2: // Connect to an existing account
  158.  
  159. //I need to add a read-write function
  160.  
  161.  
  162. case 3: // Delete an account
  163. //I need to add a read-write function
  164. cout << "display map element names2" <<endl;
  165. break;
  166.  
  167. case 4: // Display all accounts
  168. //I need to add a read-write function
  169.  
  170. for (int number(0); number < siteName.size(); number++){
  171.  
  172. cout << siteName[number]<< endl;
  173. }
  174. cin.get();
  175.  
  176. break;
  177.  
  178. default:
  179. cout << "The character you wrote isn't listed in the options" <<endl;
  180. cin.get();
  181. return main();
  182. break;
  183.  
  184.  
  185.  
  186. } // End of the choice sequence
  187.  
  188. cin.get();
  189. return 0;
  190.  
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement