Untitled
unknown
plain_text
2 years ago
16 kB
11
Indexable
#include <iostream>
#include <limits>
#include <string.h>
#include <vector>
using namespace std;
struct Location {
string locationTitle;
string locationAddress;
Location(string title, string address) {
locationTitle = title;
locationAddress = address;
}
};
bool signOut();
void menu(string firstName);
int exitApp();
bool signOut() {
int choice;
cout << "*************************************************************************************************************\n"
<< "\t\t\t| SIGN OUT? |\n"
<< "*************************************************************************************************************\n"
<< "| Choose in the options below: |\n"
<< "| [1] Close The Application |\n"
<< "| [2] Go back to log in/ sign up |\n"
<< "*************************************************************************************************************";
cout << "Enter your choice: ";
cin >> choice;
if (choice == 1) {
return true;
} else if (choice == 2) {
return false;
}
}
int exitApp() {
char choice;
cout << "*************************************************************************************************************\n"
<< "Would you like to choose another category? [Y] or [N]: ";
cin >> choice;
if (choice == 'y' || choice == 'Y') {
return 1;
} else if (choice == 'n' || choice == 'N') {
return 2;
} else {
cout << "Invalid Input.\n\n";
}
cout << "*************************************************************************************************************";
return 0;
}
void menu(string firstName) {
system("cls");
cout << "\nBGC_ONE" << endl;
cout << "*************************************************************************************************************" << endl;
cout << "Hi " << firstName << " ! Welcome to BGC_ONE! Your all in one!" << endl;
cout << "Choose the corresponding letter of category to explore:" << endl;
cout << "*************************************************************************************************************" << endl;
cout << "\t\t\t\t\t| CATEGORIES |" << endl;
cout << "*************************************************************************************************************" << endl;
cout << "[A] Malls in BGC" << endl;
cout << "[B] Tourist Spots" << endl;
cout << "[C] Places to Stay (Condos and Hotels)" << endl;
cout << "[D] Hospitals near me" << endl << endl;
cout << "[E] Exit program." << endl;
}
int main() {
system("cls");
int choice;
bool loggedIn = false;
bool agreedToTerms = false;
bool loginSuccessful = false;
string loggedInUser = "";
vector<string> usernameBank;
vector<string> passwordBank;
vector<Location> malls;
vector<Location> spots;
vector<Location> condoHotel;
vector<Location> hospital;
Location upTown("Uptown Mall", "Uptown Mall, 9th Ave, Taguig, Metro Manila");
malls.push_back(upTown);
Location veniceGrandCanal("Venice Grand Canal", "Venice Grand Canal Mall, McKinley Hill Drive, Taguig, Metro Manila");
malls.push_back(veniceGrandCanal);
Location sMAura("SM Aura", "SM Aura Premier, McKinley Parkway, Taguig, Metro Manila");
malls.push_back(sMAura);
Location theMindMuseum("The Mind Museum", "JY Campos Park, 3rd Ave, Taguig, 1634");
spots.push_back(theMindMuseum);
Location burgosCirclePark("Burgos Circle Park", "Town Center, 29th Street, Fort Bonifacio, Taguig, 1630");
spots.push_back(burgosCirclePark);
Location bGCArtsCenter("BGC Arts Center", "26th St, Taguig, Metro Manila");
spots.push_back(bGCArtsCenter);
Location grandHyattManila("Grand Hyatt Manila", "8th Avenue, Corner 35th St, Taguig, 1634 Metro Manila");
condoHotel.push_back(grandHyattManila);
Location goldbergHotel("Goldberg Hotel", "Cpg Estate, 11a General Espino, Taguig, 1630 Metro Manila");
condoHotel.push_back(goldbergHotel);
Location aureliaResidences("Aurelia Residences", "4th Ave, Taguig, Metro Manila");
condoHotel.push_back(aureliaResidences);
Location stlukes("St. Luke's Medical Center", "5th Ave, Taguig, 1634 Metro Manila");
hospital.push_back(stlukes);
Location medcenter("Medical Center Taguig, Inc.", "Levi B. Mariano Ave, Taguig, 1630 Metro Manila");
hospital.push_back(medcenter);
Location sttherese("St. Therese Hospital", "6 Sampaguita St, Taguig, 1218 Metro Manila");
hospital.push_back(sttherese);
// initialize accounts
usernameBank.push_back("q"); // 0
usernameBank.push_back("Jeth"); // 1
usernameBank.push_back("Jyke"); // 2
passwordBank.push_back("q");
passwordBank.push_back("jeth123");
passwordBank.push_back("jyke123");
while (true) {
if (!loggedIn && !agreedToTerms) {
cout << "Hello Dear user! Choose between the two options below to continue." << endl;
cout << "[1] Log In" << endl;
cout << "[2] Sign Up" << endl;
cout << "Enter your choice: ";
cin >> choice;
if (cin.fail()) { // Clear the error flag and ignore the invalid input
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "Invalid choice. Please enter 1 or 2." << endl;
continue;
}
if (choice == 1) {
// Implement Login functionality
string username, password;
cout << "************************************" << endl;
cout << "| LOG IN |" << endl;
cout << "************************************" << endl;
cout << "Username: ";
cin >> username;
cout << "Password: ";
cin >> password;
for (size_t i = 0; i < usernameBank.size(); ++i) {
if (usernameBank[i] == username && passwordBank[i] == password) {
loginSuccessful = true;
loggedInUser = username;
loggedIn = true;
break; // Exit the loop as soon as a match is found
}
}
if (!loginSuccessful) {
cout << "Login failed. Please try again." << endl;
} else {
cout << "Login successful! Welcome, " << username << "!" << endl;
agreedToTerms = false;
loggedIn = true;
}
} else if (choice == 2) {
// Implement Sign Up functionality
string username, password, confirmPassword;
cout << "************************************" << endl;
cout << "| SIGN UP |" << endl;
cout << "************************************" << endl;
cout << "Username: ";
cin >> username;
cout << "Password: ";
cin >> password;
cout << "Confirm Password: ";
cin >> confirmPassword;
if (password == confirmPassword) {
usernameBank.push_back(username); // add username to usernameBank vector
passwordBank.push_back(password); // add password to passwordBank vector
cout << "Account created successfully." << endl;
} else {
cout << "Password and confirm password do not match. Please try again." << endl;
}
} else {
cout << "Invalid choice. Please enter 1 or 2." << endl;
}
}
if (loggedIn && !agreedToTerms) {
string agree;
while (true) {
cout << "Terms and Conditions:\n";
cout << "By using this application, you agree to the following terms and conditions:\n";
cout << "1. You are responsible for maintaining the confidentiality of your account.\n";
cout << "2. You must not share your login information with others.\n";
cout << "3. You agree to use the application responsibly and lawfully.\n";
cout << "4. Any violation of these terms may result in the termination of your account.\n";
cout << "By typing ' Agree ' you accept these terms and conditions: ";
cin.ignore(10000, '\n');
getline(cin, agree);
if (agree == "Agree" || agree == "agree" || agree == "AGREE") {
cout << "You have agreed to the terms and conditions. Welcome to the application!" << endl;
agreedToTerms = true;
break;
} else {
cout << "Invalid answer. Please try again." << endl;
}
}
}
if (loggedIn && agreedToTerms) {
bool running = true;
while (running) {
menu(loggedInUser);
char ch;
cout << "\n\nEnter your choice: ";
cin >> ch;
switch (ch) {
case 'a':
case 'A':
system("cls");
cout << "***************************************************************************************************\n"
<< " | MALLS IN BGC |\n"
<< "****************************************************************************************************\n";
for (size_t i = 0; i < malls.size(); ++i) {
cout << " \t\t " << malls[i].locationTitle << "\t\t\t\n";
cout << " \t\t - Address: " << malls[i].locationAddress << "\t\t\t\n\n";
}
cout << "***************************************************************************************************\n";
if (exitApp() == 2) {
if (signOut()) {
exit(0);
} else if (!signOut()) {
loggedIn = false;
agreedToTerms = false;
continue;
}
} else {
break;
}
case 'b':
case 'B':
system("cls");
cout << "***************************************************************************************************\n"
<< " | TOURIST SPOTS IN BGC |\n"
<< "****************************************************************************************************\n";
for (size_t i = 0; i < spots.size(); ++i) {
cout << " \t\t " << spots[i].locationTitle << "\t\t\t\n";
cout << " \t\t - Address: " << spots[i].locationAddress << "\t\t\t\n\n";
}
if (exitApp() == 2) {
if (signOut()) {
exit(0);
} else if (!signOut()) {
loggedIn = false;
agreedToTerms = false;
continue;
}
} else {
break;
case 'c':
case 'C':
system("cls");
cout << "***************************************************************************************************\n"
<< " | PLACES TO STAY (CONDOS AND HOTELS) |\n"
<< "****************************************************************************************************\n";
for (size_t i = 0; i < condoHotel.size(); ++i) {
cout << " \t\t " << condoHotel[i].locationTitle << "\t\t\t\n";
cout << " \t\t - Address: " << condoHotel[i].locationAddress << "\t\t\t\n\n";
}
if (exitApp() == 2) {
if (signOut()) {
exit(0);
} else if (!signOut()) {
loggedIn = false;
agreedToTerms = false;
continue;
}
} else {
break;
case 'd':
case 'D':
system("cls");
cout << "***************************************************************************************************\n"
<< " | HOSPITALS |\n"
<< "****************************************************************************************************\n";
for (size_t i = 0; i < hospital.size(); ++i) {
cout << " \t\t " << hospital[i].locationTitle << "\t\t\t\n";
cout << " \t\t - Address: " << hospital[i].locationAddress << "\t\t\t\n\n";
}
if (exitApp() == 2) {
if (signOut()) {
exit(0);
} else if (!signOut()) {
loggedIn = false;
agreedToTerms = false;
continue;
}
} else {
break;
case 'e':
case 'E':
system("cls");
char restart;
cout << "\t Do you want to restart? (Y/N) ";
cin >> restart;
if (restart == 'Y' || restart == 'y'){
cin.ignore();
main();
} else if (restart == 'N' || restart == 'n') {
return 0;
}
break;
}
}
break;
}
}
}
return 0;
}
}
}
Editor is loading...
Leave a Comment