Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Denkotleta221/c2e4bbe18075fde9ea3982930b077767 to your computer and use it in GitHub Desktop.
Save Denkotleta221/c2e4bbe18075fde9ea3982930b077767 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <windows.h>
#include <conio.h>
using namespace std;
void log_in();
void main_menu();
void admin();
void sign_in();
void admin_menu();
void category();
void start(string text = "") {
system("cls");
cout << "Welcome to 'My Store'\n";
int choice;
cout << "1. Log in\n";
cout << "2. Sign in \n";
cout << "3. Admin\n";
cout << text;
cin >> choice;
switch (choice) {
case 1: log_in();
break;
case 2: sign_in();
break;
case 3: admin();
break;
default:
cout << "Invalid choice. Please try again.\n";
start();
break;
}
}
void log_in() {
system("cls");
string name, pass;
cout << "Log in: \n";
cout << "Enter your name: ";
cin >> name;
cout << "\nEnter your password: ";
cin >> pass;
cout << "Thank you for logging in!\n";
main_menu();
}
void sign_in() {
system("cls");
static string name, pass;
cout << "Sign in: \n";
cout << "Enter your name: ";
cin >> name;
cout << "\nEnter your password: ";
cin >> pass;
cout << "Thank you for signing up! You can now log in.\n";
main_menu();
}
void main_menu() {
system("cls");
cout << "Main Menu: \n";
cout << "1. Categories\n";
cout << "2. Cart\n";
cout << "3. Exit\n";
int choice;
cin >> choice;
switch (choice) {
case 1:
cout << "Displaying category...\n";
category();
break;
case 2:
cout << "Displaying cart...\n";
break;
case 3:
cout << "Exiting the store. Goodbye!\n";
exit(0);
break;
default:
cout << "Invalid choice. Please try again.\n";
main_menu();
break;
}
}
void category() {
system("cls");
int size = 5;
string categories[] = { "Dairy", "Cereals", "Bakery", "Meat", "Fruits" };
for (int i = 0; i < size; i++) {
cout << i + 1 << ". " << categories[i] << "\n";
}
int category_choice;
cout << "\nChoose a category (1-" << size << "): ";
cin >> category_choice;
if (category_choice < 1 || category_choice > size) {
cout << "Invalid choice.\n";
category();
}
else {
switch (category_choice) {
case 1:
break;
}
}
}
void admin_menu() {
system("cls");
cout << "Admin Menu: \n";
cout << "1. Change Catalog\n";
cout << "2. View Users\n";
cout << "3. Exit\n";
int choice;
cin >> choice;
switch (choice) {
case 1:
cout << "Change catalog functionality (not implemented yet).\n";
break;
case 2:
cout << "View users functionality (not implemented yet).\n";
break;
case 3:
cout << "Exiting admin menu.\n";
break;
default:
cout << "Invalid choice. Please try again.\n";
admin_menu();
break;
}
}
void admin() {
system("cls");
string name, pass;
cout << "Admin Login: \n";
cout << "Enter your name: ";
cin >> name;
cout << "\nEnter your password: ";
cin >> pass;
if (name == "admin228" and pass == "123") { // pass and loign to admin
admin_menu();
}
start("Dont corect password or login!!!\n(check description in the code)");
}
int main() {
while (true) {
start();
}
}
@KuRRe8
Copy link

KuRRe8 commented May 10, 2025

Is it an online shopping management system?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment