void userLogin() { string username, password; if (!loginStatus) { cout << "Login to existing account" << endl; cout << "Enter username: "******"Enter password for " << username << ": "; cin >> password; if (usernetwork.checkPassword(username, password)) { cout << "Login successful. " << endl; loginStatus = true; uname = username; curr_user = usernetwork.getUser(username); return; } else { cout << "Login unsuccessful. " << endl; return; } }
void createUser() { string username, firstname, lastname, password; int date[3] = { 0, 0, 0 };//day, month, year; cout << "Creating new user account" << endl; cout << "Enter desired username: "******"Username taken." << endl; else { cout << "Please enter a password: "******"Please enter your first name: "; cin >> firstname; cout << "Please enter your last name: "; cin >> lastname; cout << "Enter your date of birth." << endl; cout << "Day: (dd) "; while (!(cin >> date[0]) || date[0] > 31 || date[0] < 1) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << "Please input a valid day: " << endl; } cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << "Month: (mm) "; while (!(cin >> date[1]) || date[1] > 12 || date[1] < 1) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << "Please input a valid month: " << endl; } cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << "Year: (yyyy) "; while (!(cin >> date[2]) || date[2] > 2015 || date[2] < 1900) { cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); cout << "Please input a valid year: " << endl; } cin.clear(); cin.ignore(numeric_limits<streamsize>::max(), '\n'); stringstream formatString; formatString << username << " " << password << " " << firstname << " " << lastname << " " << date[0] << " " << date[1] << " " << date[2]; User newUser(formatString.str()); // cout << formatString.str() << endl; usernetwork.addUser(newUser); //usernetwork.printUsers(); cout << "User has been added successfully." << endl; } }