Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "User.h"
  4. #include "Vehicle.h"
  5. #include "Route.h"
  6.  
  7. class Session {
  8. private:
  9. static Session* singleton_instance;
  10.  
  11. public:
  12. static Session* instance();
  13.  
  14. vector<Registered> registered;
  15. vector<string> districts;
  16. string username;
  17.  
  18. bool importUsers();
  19. bool importDistricts();
  20.  
  21. void login();
  22. void registration();
  23. string passwordMaker();
  24. };
  25.  
  26. #include "Session.h"
  27. #include "User.h"
  28.  
  29. Session* Session::instance() {
  30. if (!singleton_instance) {
  31. singleton_instance = new Session;
  32. }
  33. return singleton_instance;
  34. }
  35.  
  36. #pragma once
  37. using namespace std;
  38.  
  39. class Menu {
  40. public:
  41. int menu1();
  42. int menu2();
  43. vector<string> journeyMenu();
  44. };
  45.  
  46. #include "Menu.h"
  47. #include "Utilities.h"
  48. #include "Session.h"
  49.  
  50. Utilities u;
  51.  
  52. vector<string> Menu::journeyMenu() {
  53. u.hideCursor();
  54.  
  55. vector<string> localDistricts = Session::instance()->districts;
  56. vector<string> selectedDistricts;
  57. size_t selectedIndex = 0;
  58.  
  59. while (!GetAsyncKeyState(VK_SHIFT) && !GetAsyncKeyState(VK_RETURN)) {
  60. for (size_t i = 0; localDistricts.size(); i++) {
  61.  
  62. if (i == selectedIndex) {
  63. u.whiteBG();
  64. cout << i - 1 << ". " << localDistricts.at(i);
  65. u.blackBG();
  66. }
  67. else {
  68. cout << i - 1 << ". " << localDistricts.at(i);
  69. }
  70. }
  71. if (GetAsyncKeyState(VK_RETURN)) {
  72. selectedDistricts.push_back(localDistricts.at(selectedIndex));
  73. }
  74. else if ((GetAsyncKeyState(VK_DOWN) && selectedIndex == localDistricts.size()) || (GetAsyncKeyState(VK_UP) && selectedIndex == 0)) {
  75. continue;
  76. }
  77. else if (GetAsyncKeyState(VK_DOWN)) {
  78. selectedIndex += 1;
  79. }
  80. else if (GetAsyncKeyState(VK_UP)) {
  81. selectedIndex -= 1;
  82. }
  83. }
  84. return selectedDistricts;
  85. }
  86.  
  87. #pragma once
  88.  
  89. #include <string>
  90. #include <vector>
  91.  
  92. #include "Vehicle.h"
  93. using namespace std;
  94.  
  95. class User{
  96. protected:
  97. string username;
  98. public:
  99. User();
  100. };
  101.  
  102. class Registered : public User{
  103. private:
  104. string name, password;
  105. unsigned int age;
  106.  
  107. vector<Vehicle> garage;
  108. vector<vector<string>> trips; //vector with all registered trips.
  109. vector<Registered> buddies;
  110. public:
  111. Registered(string name, unsigned int age, string username, string password);
  112.  
  113. string getUsername();
  114. string getPassword();
  115. void hostJourney();
  116. void addBuddy();
  117.  
  118. };
  119.  
  120. class Guest : public User{
  121. public:
  122. Guest(string username);
  123. };
  124.  
  125. #include "User.h"
  126. #include "Session.h"
  127. #include "Route.h"
  128. #include "Session.h"
  129. #include "Menu.h"
  130.  
  131. Menu m;
  132.  
  133. /*USER CLASS*/
  134. User::User() {
  135. }
  136.  
  137. /*REGISTERED CLASS*/
  138. Registered::Registered(string name, unsigned int age, string username, string password){
  139. this->username = username;
  140. this->password = password;
  141. }
  142. string Registered::getPassword(){
  143. return password;
  144. }
  145. string Registered::getUsername() {
  146. return username;
  147. }
  148.  
  149. void Registered::hostJourney() {
  150.  
  151. vector<string> stops = m.journeyMenu(); //THIS DOESN'T WORK.
  152. m.menu1(); //THIS ALSO RETURNS ERROR LNK2019 UNRESOLVED EXTERNAL SYMBOL.
  153. return;
  154. }
  155.  
  156. void Registered::addBuddy() {
  157. string username;
  158. bool foundUsername = false;
  159.  
  160. while (!foundUsername) {
  161.  
  162. cout << "Type in the username of the user you would like to add: ";
  163. cin >> username;
  164.  
  165. for (size_t i = 0; i < Session::instance()->registered.size(); i++) {
  166. if (Session::instance()->registered.at(i).getUsername() == username) {
  167. foundUsername = true;
  168. buddies.push_back(Session::instance()->registered.at(i));
  169. }
  170. }
  171. if (!foundUsername) {
  172. cout << "That user does not exist. Please try again.";
  173. continue;
  174. }
  175. }
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement