Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <fstream>
- #include "windows.h"
- using namespace std;
- // Function timer in seconds
- void timer(int sec)
- {
- Sleep(sec*1000);
- }
- //Save function
- void saveFunction(ofstream save, string site, string url, string username, string password)
- {
- save << site << endl;
- save << url << endl;
- save << username << endl;
- save << password << endl;
- }
- //Load Function
- // Main program
- int main()
- {
- int userAction; // Variable used to select an option
- string siteNameVar("site"), urlVar("url"), userNameVar("username"), passwordVar("pass") ;
- char sureVerification;
- vector<string> siteName(0); // Vectors containing respectively : "The sites names"
- vector<string> url(0); // Vectors containing respectively : "The sites urls"
- vector<string> userName(0); // Vectors containing respectively : "The usernames"
- vector<string> password(0); // Vectors containing respectively : "The passwords"
- ofstream Save("Account Manager/Save.txt"); //Trying to open the save file
- if(Save) //Testing
- {
- //Ok it's working
- }
- else
- {
- cout << "ERROR. The file it is impossible to open the file" << endl; //Shit!
- }
- cout << "What will you do?" << endl;
- cout << "1. Add a website account" << endl
- << "2. Connect to an existing account" << endl
- << "3. Delete an account"<< endl
- << "4. See all the existing accounts" << endl;
- cin >> userAction; // This is where the user enter his choice
- switch (userAction){
- case 1: // Add a new element in the vectors
- system("cls");
- //Adding elements sequence
- //Site Name
- do{
- cout << "Enter the website name" <<endl;
- cin >> siteNameVar;
- cout << "Are you sure? 1: Yes Anything Else: False" <<endl;
- cin >> sureVerification;
- system("cls");
- }
- while(sureVerification != '1');
- system("cls");
- siteName.push_back(siteNameVar);
- //Site's Url
- do{
- cout << "Enter the site's login page url" << endl;
- cin >> urlVar;
- cout << "Are you sure? 1 = yes | Anything else = no" << endl;
- cin >> sureVerification;
- system("cls");
- }
- while(sureVerification != '1');
- system("cls");
- url.push_back(urlVar);
- // Username
- do{
- cout << "Enter your account's username" << endl;
- cin >> userNameVar;
- cout << "Are you sure? 1 = yes | Anything else = no" << endl;
- cin >> sureVerification;
- system("cls");
- }
- while(sureVerification != '1');
- system("cls");
- userName.push_back(userNameVar);
- // Password
- do{
- cout << "Enter your account's password" << endl;
- cin >> passwordVar;
- cout << "Are you sure? 1 = yes | Anything else = no" << endl;
- cin >> sureVerification;
- system("cls");
- }
- while(sureVerification != '1');
- system("cls");
- password.push_back(passwordVar);
- //Display Everything
- cout << "So the site's name is :" << siteName.back() << endl
- << "The login page url is :" << url.back() << endl
- << "Your account's username is :" << userName.back() << endl
- << "And your password is :" << password.back() << endl;
- cout << endl << "Wait 5 seconds " << endl;
- //Where all the values are saved in vectors
- saveFunction(Save, siteName, url, userName, password);
- // I need to add a save function
- //Get back to the main()
- timer(5);
- system("cls");
- return main();
- case 2: // Connect to an existing account
- //I need to add a read-write function
- case 3: // Delete an account
- //I need to add a read-write function
- cout << "display map element names2" <<endl;
- break;
- case 4: // Display all accounts
- //I need to add a read-write function
- for (int number(0); number < siteName.size(); number++){
- cout << siteName[number]<< endl;
- }
- cin.get();
- break;
- default:
- cout << "The character you wrote isn't listed in the options" <<endl;
- cin.get();
- return main();
- break;
- } // End of the choice sequence
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement