Advertisement
Guest User

Untitled

a guest
Sep 29th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.81 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<fstream>
  4. #include<vector>
  5.  
  6. using namespace std;
  7.  
  8. class User
  9. {
  10.     string username;
  11.     string password;
  12. public:
  13.     void Register()
  14.     {
  15.         ofstream File("MyFile.txt");
  16.         File.open("MyFile.txt");
  17.         cout << "Enter the Username" << endl;
  18.         cin >> username;
  19.         File << username << endl;
  20.         cout << "Enter the Password" << endl;
  21.         cin >> password;
  22.         File << password << endl;  
  23.     }
  24.     void LogIn(string EnteredUser, string EnteredPassword)
  25.     {
  26.         cout << "Enter your Registered UserName " << endl;
  27.         cin >> EnteredUser;
  28.         cout << "Enter your Password " << endl;
  29.         cin >> EnteredPassword;
  30.         ifstream CheckAcc;
  31.         CheckAcc.open("MyFile.txt");
  32.         CheckAcc >> username;
  33.         cout << "Username from the database\t" << username << endl;
  34.         CheckAcc >> password;
  35.         cout << "Password from the database\t" << password << endl;
  36.  
  37.  
  38.         if (EnteredUser == username && EnteredPassword == password) {
  39.             cout << "Log in is Succsesfull " << endl;
  40.             cout << "Do you want to remove all your info ? " << endl;
  41.             cout << "1 / 0 " << endl;
  42.             bool choose;
  43.             cin >> choose;
  44.             if (choose) {
  45.  
  46.                 cout << "Are you Sure ? " << endl;
  47.                 cout << "1 / 0 " << endl;
  48.                 bool SureChoose;
  49.                 cin >> SureChoose;
  50.                 if (SureChoose)
  51.                     DeleteInfo();
  52.             }
  53.             else LogIn(username, password);
  54.         }
  55.         else
  56.             cout << "Either username or password was entered incorrectly" << endl;
  57. }
  58. void DeleteInfo() {
  59.   ofstream DelInfo;
  60.   DelInfo.open("MyFile.txt");
  61.   DelInfo.clear();
  62.   DelInfo.close();
  63.   cout << "All of your info was removed from file ! " << endl;
  64. }
  65. };
  66. class User1 : public User
  67. {
  68. };
  69. class User2 : public User
  70. {
  71.  
  72. };
  73. int main()
  74. {
  75.     User1 user1;
  76.     User2 user2;
  77.     user1.Register();
  78.     user2.Register();
  79.     user1.LogIn("s", "b");
  80.     user2.LogIn("a", "b");
  81.     cin.get();
  82.     cin.get();
  83.     return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement