Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "User.h"
- #include "Vehicle.h"
- #include "Route.h"
- class Session {
- private:
- static Session* singleton_instance;
- public:
- static Session* instance();
- vector<Registered> registered;
- vector<string> districts;
- string username;
- bool importUsers();
- bool importDistricts();
- void login();
- void registration();
- string passwordMaker();
- };
- #include "Session.h"
- #include "User.h"
- Session* Session::instance() {
- if (!singleton_instance) {
- singleton_instance = new Session;
- }
- return singleton_instance;
- }
- #pragma once
- using namespace std;
- class Menu {
- public:
- int menu1();
- int menu2();
- vector<string> journeyMenu();
- };
- #include "Menu.h"
- #include "Utilities.h"
- #include "Session.h"
- Utilities u;
- vector<string> Menu::journeyMenu() {
- u.hideCursor();
- vector<string> localDistricts = Session::instance()->districts;
- vector<string> selectedDistricts;
- size_t selectedIndex = 0;
- while (!GetAsyncKeyState(VK_SHIFT) && !GetAsyncKeyState(VK_RETURN)) {
- for (size_t i = 0; localDistricts.size(); i++) {
- if (i == selectedIndex) {
- u.whiteBG();
- cout << i - 1 << ". " << localDistricts.at(i);
- u.blackBG();
- }
- else {
- cout << i - 1 << ". " << localDistricts.at(i);
- }
- }
- if (GetAsyncKeyState(VK_RETURN)) {
- selectedDistricts.push_back(localDistricts.at(selectedIndex));
- }
- else if ((GetAsyncKeyState(VK_DOWN) && selectedIndex == localDistricts.size()) || (GetAsyncKeyState(VK_UP) && selectedIndex == 0)) {
- continue;
- }
- else if (GetAsyncKeyState(VK_DOWN)) {
- selectedIndex += 1;
- }
- else if (GetAsyncKeyState(VK_UP)) {
- selectedIndex -= 1;
- }
- }
- return selectedDistricts;
- }
- #pragma once
- #include <string>
- #include <vector>
- #include "Vehicle.h"
- using namespace std;
- class User{
- protected:
- string username;
- public:
- User();
- };
- class Registered : public User{
- private:
- string name, password;
- unsigned int age;
- vector<Vehicle> garage;
- vector<vector<string>> trips; //vector with all registered trips.
- vector<Registered> buddies;
- public:
- Registered(string name, unsigned int age, string username, string password);
- string getUsername();
- string getPassword();
- void hostJourney();
- void addBuddy();
- };
- class Guest : public User{
- public:
- Guest(string username);
- };
- #include "User.h"
- #include "Session.h"
- #include "Route.h"
- #include "Session.h"
- #include "Menu.h"
- Menu m;
- /*USER CLASS*/
- User::User() {
- }
- /*REGISTERED CLASS*/
- Registered::Registered(string name, unsigned int age, string username, string password){
- this->username = username;
- this->password = password;
- }
- string Registered::getPassword(){
- return password;
- }
- string Registered::getUsername() {
- return username;
- }
- void Registered::hostJourney() {
- vector<string> stops = m.journeyMenu(); //THIS DOESN'T WORK.
- m.menu1(); //THIS ALSO RETURNS ERROR LNK2019 UNRESOLVED EXTERNAL SYMBOL.
- return;
- }
- void Registered::addBuddy() {
- string username;
- bool foundUsername = false;
- while (!foundUsername) {
- cout << "Type in the username of the user you would like to add: ";
- cin >> username;
- for (size_t i = 0; i < Session::instance()->registered.size(); i++) {
- if (Session::instance()->registered.at(i).getUsername() == username) {
- foundUsername = true;
- buddies.push_back(Session::instance()->registered.at(i));
- }
- }
- if (!foundUsername) {
- cout << "That user does not exist. Please try again.";
- continue;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement