Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "manager.h"
- manager::manager()
- {
- user = new myprofile();
- }
- manager::~manager()
- {
- delete user;
- }
- void manager::Log_In(std::string username,std::string password)
- {
- for (int i = 0; i < accounts.size(); i++)
- {
- if (accounts[i]->get_Name() == username)
- {
- if (accounts[i]->get_Password() == password)
- {
- user = accounts[i];
- userID = i;
- logged = true;
- return;
- }
- }
- }
- }
- void manager::Log_Out()
- {
- logged = false;
- user = nullptr;
- }
- void manager::sign_up(std::string username, std::string password)
- {
- myprofile *_profile=new myprofile();
- _profile->set_Name(username);
- _profile->set_Password(password);
- _profile->set_ID(accounts.size());
- accounts.push_back(_profile);
- }
- void manager::commander()
- {
- Directory = "Log In>>";
- std::string command;
- while (1)
- {
- std::cout << Directory<<std::endl;
- std::cout << "Enter username : ";
- std::string _username,_password;
- std::getline(std::cin, _username);
- std::cout << "Enter password : ";
- std::getline(std::cin, _password);
- Log_In(_username, _password);
- if (!logged)
- {
- std::cout << std::endl << "Wrong Username or Password "<<"type 't' to try again or \"Sign Up\" to sign up"<<std::endl;
- std::getline(std::cin, command);
- if (command == "t")
- continue;
- else if (command == "Sign Up")
- {
- std::cout << "Sign Up : " << std::endl;
- std::cout << "Enter username : ";
- std::string _username, _password;
- std::getline(std::cin, _username);
- std::cout << "Enter password : ";
- std::getline(std::cin, _password);
- sign_up(_username, _password);
- continue;
- }
- }
- while(logged)
- {
- Directory = "My Profile>>";
- std::cout << Directory;
- user->list_posts();
- while (logged)
- {
- std::getline(std::cin, command);
- if (command == "My Posts")
- user->list_posts();
- else if (command == "My Friends")
- user->list_Friends();
- else if (command == "My Groups")
- user->list_Groups();
- else if (command == "Write Post")
- {
- std::string s;
- std::getline(std::cin, s);
- user->write_Post(s);
- }
- else if (command == "Log out")
- {
- user = nullptr;
- Directory = "Log in >>";
- logged = 0;
- break;
- }
- else if (command.substr(0, 6) == "Remove")
- {
- }
- }
- }
- }
- }
- void manager::add_group(std::string groupName)
- {
- group *_group = new group();
- _group->set_Name(groupName);
- _group->set_Admin(user->get_Name());
- Groups.push_back(_group);
- }
- void manager::add_profile(myprofile* _profile)
- {
- accounts.push_back(_profile);
- }
- void manager::add_group(group* _group)
- {
- Groups.push_back(_group);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement