Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- #include <string>
- using namespace std;
- void mainMenu();
- void start();
- class UserRoot
- {
- public:
- std::string root_username;
- std::string root_password;
- void setRootUsername(std::string _root_username_)
- {
- this->root_username = _root_username_;
- }
- void setRootPassword(std::string _root_password_)
- {
- this->root_password = _root_password_;
- }
- friend ostream& operator<<(ostream& archive, const UserRoot& root)
- {
- archive << std::endl << "USER: " << root.root_username << std::endl <<
- "PASSWORD: " << root.root_password;
- return archive;
- }
- };
- UserRoot root;
- int main()
- {
- mainMenu();
- }
- void mainMenu()
- {
- char user_option;
- std::cout << std::endl << "\t\tWELCOME TO LINUX OS" << std::endl;
- std::cout << std::endl << "\t\t1_SET YOUR SETTINGS" <<std::endl;
- std::cout << "\t\t2_ENTER IN SYSTEM" << std::endl;
- std::cout << "\t\t3_EXIT" << std::endl;
- std::cout << std::endl << "\t\tOption: ";
- std::cin >> user_option;
- switch(user_option)
- {
- case '1':
- {
- try
- {
- start();
- } catch(const char *Exception) {
- std::cerr << Exception;
- }
- }
- case '2':
- {
- }
- case '3':
- {
- }
- }
- }
- void start()
- {
- std::string username;
- std::string password;
- std::cout << std::endl << "\t\tSET YOUR NEW SETTINGS" << std::endl;
- std::cin.ignore();
- std::cout << std::endl << "\t\tUSERNAME: ";
- std::getline(cin, username);
- if(username.empty())
- throw "\t\tFAIL. STR EMPTY";
- root.setRootUsername(username);
- std::cout << "\t\tPASSWORD: ";
- std::getline(cin, password);
- if(password.empty())
- throw "\t\tFAIL. STR EMPTY";
- root.setRootPassword(password);
- ofstream archive("RootSettings.txt", fstream::app);
- archive << root;
- archive.close();
- exit(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement