Advertisement
Guest User

Untitled

a guest
May 13th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. #include "manager.h"
  2.  
  3.  
  4. manager::manager()
  5. {
  6. user = new myprofile();
  7. }
  8.  
  9.  
  10. manager::~manager()
  11. {
  12. delete user;
  13. }
  14.  
  15.  
  16. void manager::Log_In(std::string username,std::string password)
  17. {
  18. for (int i = 0; i < accounts.size(); i++)
  19. {
  20. if (accounts[i]->get_Name() == username)
  21. {
  22. if (accounts[i]->get_Password() == password)
  23. {
  24. user = accounts[i];
  25. userID = i;
  26. logged = true;
  27. return;
  28. }
  29. }
  30. }
  31. }
  32.  
  33.  
  34. void manager::Log_Out()
  35. {
  36. logged = false;
  37. user = nullptr;
  38. }
  39.  
  40.  
  41. void manager::sign_up(std::string username, std::string password)
  42. {
  43. myprofile *_profile=new myprofile();
  44. _profile->set_Name(username);
  45. _profile->set_Password(password);
  46. _profile->set_ID(accounts.size());
  47. accounts.push_back(_profile);
  48. }
  49.  
  50.  
  51. void manager::commander()
  52. {
  53. Directory = "Log In>>";
  54. std::string command;
  55. while (1)
  56. {
  57. std::cout << Directory<<std::endl;
  58. std::cout << "Enter username : ";
  59. std::string _username,_password;
  60. std::getline(std::cin, _username);
  61. std::cout << "Enter password : ";
  62. std::getline(std::cin, _password);
  63. Log_In(_username, _password);
  64. if (!logged)
  65. {
  66. std::cout << std::endl << "Wrong Username or Password "<<"type 't' to try again or \"Sign Up\" to sign up"<<std::endl;
  67. std::getline(std::cin, command);
  68. if (command == "t")
  69. continue;
  70. else if (command == "Sign Up")
  71. {
  72. std::cout << "Sign Up : " << std::endl;
  73. std::cout << "Enter username : ";
  74. std::string _username, _password;
  75. std::getline(std::cin, _username);
  76. std::cout << "Enter password : ";
  77. std::getline(std::cin, _password);
  78. sign_up(_username, _password);
  79. continue;
  80. }
  81. }
  82.  
  83. while(logged)
  84. {
  85. Directory = "My Profile>>";
  86. std::cout << Directory;
  87. user->list_posts();
  88. while (logged)
  89. {
  90. std::getline(std::cin, command);
  91. if (command == "My Posts")
  92. user->list_posts();
  93. else if (command == "My Friends")
  94. user->list_Friends();
  95. else if (command == "My Groups")
  96. user->list_Groups();
  97. else if (command == "Write Post")
  98. {
  99. std::string s;
  100. std::getline(std::cin, s);
  101. user->write_Post(s);
  102. }
  103. else if (command == "Log out")
  104. {
  105. user = nullptr;
  106. Directory = "Log in >>";
  107. logged = 0;
  108. break;
  109. }
  110.  
  111. else if (command.substr(0, 6) == "Remove")
  112. {
  113.  
  114. }
  115.  
  116. }
  117. }
  118. }
  119. }
  120.  
  121.  
  122. void manager::add_group(std::string groupName)
  123. {
  124. group *_group = new group();
  125. _group->set_Name(groupName);
  126. _group->set_Admin(user->get_Name());
  127. Groups.push_back(_group);
  128. }
  129.  
  130.  
  131. void manager::add_profile(myprofile* _profile)
  132. {
  133. accounts.push_back(_profile);
  134. }
  135.  
  136.  
  137. void manager::add_group(group* _group)
  138. {
  139. Groups.push_back(_group);
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement