0% found this document useful (0 votes)
13 views21 pages

PF Project

Cricket stadium managing company

Uploaded by

harisabid88.1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views21 pages

PF Project

Cricket stadium managing company

Uploaded by

harisabid88.1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

#include <iostream>

#include <string>

#include <fstream>

#include <cstdlib>

#include <iomanip>

using namespace std;

// Macros for text styles and colors

#define RESET "\033[0m"

#define BOLD "\033[1m"

#define ITALIC "\033[3m"

#define UNDERLINE "\033[4m"

#define RED "\033[31m"

#define GREEN "\033[32m"

#define BLUE "\033[34m"

#define YELLOW "\033[33m"

#define CYAN "\033[36m"

#define MAGENTA "\033[35m"

// _____________________________________

struct UserDetails {

string name;

string email;

string phone;
};

void validateInput(int& input);

void clearScreen();

void getDetails(UserDetails& user);

void paymentDetails(const UserDetails& user, double total);

void seatBooking();

void stallBooking();

void bookByCall();

void bookByVisit();

void bookByWebsite();

void showAdvertisementOptions();

int main(){

int mainChoice;

cout<< BOLD UNDERLINE CYAN <<"Choices"<<RESET ;

validateInput(mainChoice);

switch (mainChoice){

case 1 :

seatBooking();

break;

case 2 :
stallBooking();

break;

case 3 :

break;

case 4:

showAdvertisementOptions();

break;

}}

// _____________________________________

// Function to validate numeric input

void validateInput(int& input) {

while (!(cin >> input)) { // Check if input is not a valid integer

cin.clear(); // Clear the error flag

cin.ignore(numeric_limits<streamsize>::max(), '\n'); // Discard invalid


input

cout << "Invalid input! Please enter a valid number: ";

}
}

// _____________________________________

void clearScreen() {

#ifdef _WIN32

system("cls");

#else

system("clear");

#endif

// _____________________________________

void getDetails(UserDetails& user) {

cout << "Please enter your details:" << endl;

cout << "Name: ";

cin.ignore();

getline(cin, user.name);

cout << "Email: ";

getline(cin, user.email);

cout << "Phone Number: ";

getline(cin, user.phone);

//______________________________________
// _____________________________________

void paymentDetails(const UserDetails& user, double total) {

cout << "Thank you, " << user.name << ". Your booking is confirmed."
<< endl;

cout << "Your total payment is: " << total << " PKR" << endl;

cout << "We will send the booking details to your email: " << user.email
<< "." << endl;

// _____________________________________

void seatBooking() {

int n, j, countNum = 0;

bool frontSeats[20] = { false }; // Array for front seats

bool midSeats[40] = { false }; // Array for mid seats

bool backSeats[40] = { false }; // Array for back seats

cout << "Price of each class is shown Below:" << endl;

cout << "1. Front seats (Rs. 300 per seat)" << endl;

cout << "2. Mid seats (Rs. 200 per seat)" << endl;

cout << "3. Back seats (Rs. 100 per seat)" << endl << endl;
cout << "Which class of seat do you want to choose: " << endl;

cout << "We have 3 options\n";

cout << "1. Front seat (Seat no. 1 to 20 are front seats)\n";

cout << "2. Mid seat (Seat no. 21 to 60 are mid seats)\n";

cout << "3. Back seat (Seat no. 61 to 100 are back seats)\n" << endl;

cout << "How many seats do you want to book? ";

validateInput(n);

for (int i = 0; i < n; i++) {

int seatClass;

cout << "Select seat class (1 for Front, 2 for Mid, 3 for Back): ";

validateInput(seatClass);

// Ask user to choose seat based on class

if (seatClass == 1) {

cout << "Enter your desired seat number (1 to 20): ";

validateInput(j);

if (j < 1 || j > 20) {

cout << "Invalid seat number! Please choose a valid seat number
from 1 to 20.\n";

i--; // Ask for seat again

continue;

if (frontSeats[j - 1]) { // Seat already reserved


cout << "You have already reserved this seat (seat no. " << j <<
"). Please choose another one." << endl << endl;

i--; // Ask for seat again

else {

frontSeats[j - 1] = true; // Mark the seat as booked

cout << "Seat no. " << j << " has been successfully reserved."
<< endl << endl;

countNum++;

else if (seatClass == 2) {

cout << "Enter your desired seat number (21 to 60): ";

validateInput(j);

if (j < 21 || j > 60) {

cout << "Invalid seat number! Please choose a valid seat number
from 21 to 60.\n";

i--; // Ask for seat again

continue;

if (midSeats[j - 21]) { // Seat already reserved

cout << "You have already reserved this seat (seat no. " << j <<
"). Please choose another one." << endl << endl;

i--; // Ask for seat again

else {

midSeats[j - 21] = true; // Mark the seat as booked


cout << "Seat no. " << j << " has been successfully reserved."
<< endl << endl;

countNum++;

else if (seatClass == 3) {

cout << "Enter your desired seat number (61 to 100): ";

validateInput(j);

if (j < 61 || j > 100) {

cout << "Invalid seat number! Please choose a valid seat number
from 61 to 100.\n";

i--; // Ask for seat again

continue;

if (backSeats[j - 61]) { // Seat already reserved

cout << "You have already reserved this seat (seat no. " << j <<
"). Please choose another one." << endl << endl;

i--; // Ask for seat again

else {

backSeats[j - 61] = true; // Mark the seat as booked

cout << "Seat no. " << j << " has been successfully reserved."
<< endl << endl;

countNum++;

else {
cout << "Invalid seat class! Please choose a valid option." << endl
<< endl;

i--; // Ask for valid seat class again

cout << "Congratulations! You have successfully reserved " << countNum
<< " seats." << endl;

// Display reserved seats

cout << "\nReserved Seats:\n";

// Front seats

cout << "Front seats: ";

for (int i = 0; i < 20; i++) {

if (frontSeats[i]) {

cout << (i + 1) << " ";

cout << endl;

// Mid seats

cout << "Mid seats: ";

for (int i = 0; i < 40; i++) {

if (midSeats[i]) {

cout << (i + 21) << " ";

}
}

cout << endl;

// Back seats

cout << "Back seats: ";

for (int i = 0; i < 40; i++) {

if (backSeats[i]) {

cout << (i + 61) << " ";

cout << endl;

// _____________________________________

void stallBooking() {

while (true) {

cout << "\n*** Cricket Stadium Management System ***\n";

cout << "1. Book a Stall\n";

cout << "2. Exit\n";

cout << "Enter your choice: ";

int menuChoice;

validateInput(menuChoice);

if (menuChoice == 1) {
// Stall types and prices

string stallTypes[] = {"Food", "Merchandise", "Games"};

int stallPrices[] = {500, 300, 400}; // Prices for each type of stall

// Stall locations and prices

string stallLocations[] = {"Entrance", "Exit", "Near Seats", "Other"};

int locationPrices[] = {200, 150, 100, 50}; // Prices for each location

int totalCost = 0; // Cumulative total cost

while (true) {

// Get and validate stall type

//correction

int stallChoice;

while (true) {

cout << "\nSelect a stall type:\n";

for (int i = 0; i < 3; i++) {

cout << i + 1 << ". " << stallTypes[i] << " - $" <<
stallPrices[i] << endl;

cout << "Enter your choice (1-3): ";

validateInput(stallChoice);

if (stallChoice >= 1 || stallChoice <= 3) break;

cout << "Invalid choice! Please select a valid stall type.\n";

}
// Get and validate stall location

int locationChoice;

while (true) {

cout << "\nSelect a stall location:\n";

for (int i = 0; i < 4; i++) {

cout << i + 1 << ". " << stallLocations[i] << " - $" <<
locationPrices[i] << endl;

cout << "Enter your choice (1-4): ";

validateInput(stallChoice);

if (locationChoice >= 1 && locationChoice <= 4) break;

cout << "Invalid choice! Please select a valid stall location.\n";

// Calculate base price

int basePrice = stallPrices[stallChoice - 1] +


locationPrices[locationChoice - 1];

// Get and validate the number of days

int days;

while (true) {

cout << "\nEnter the number of days you want to book the stall:
";

validateInput(days);
if (days > 0) break;

cout << "Invalid number of days! Please enter a positive


number.\n";

// Calculate total cost for this booking

int bookingCost = basePrice * days;

totalCost += bookingCost;

// Display booking cost and cumulative total cost

cout << "\nCost for this booking: $" << bookingCost << endl;

cout << "Cumulative total cost so far: $" << totalCost << endl;

// Ask if the user wants to book again

char choice;

while (true) {

cout << "\nDo you want to book another stall? (y/n): ";

cin>>choice;

if (choice == 'y' || choice == 'Y') {

break;

} else if (choice == 'n' || choice == 'N') {

cout << "Final total cost for all bookings: $" << totalCost <<
endl;

return;

} else {
cout << "Invalid input! Please enter 'y' or 'n'.\n";

} else if (menuChoice == 2) {

cout << "Thank you! Exiting the program.\n";

return;

} else {

cout << "Invalid choice! Please try again.\n";

// _____________________________________

void bookByCall() {

cout << "OPTIMA ENDURANCE - Booking via Call" << endl;

cout << "For further assistance, you can reach us at +43 68999554." <<
endl;

// _____________________________________
void bookByVisit() {

cout << "OPTIMA ENDURANCE - Booking via Office Visit" << endl;

cout << "For further assistance, you can reach us at +43 68999554 or
email us at @gmail.com." << endl;

cout << "Our office address is: OPTIMA ENDURANCE, Lahore, Punjab,
Pakistan." << endl;

// _____________________________________

void bookByWebsite() {

int subChoice, numStalls = 0, days = 0;

double total = 0;

const double groundRate = 50000;

const double seatsRate = 30000;

const double stallRate = 5000;

UserDetails user;

cout << "OPTIMA ENDURANCE - Booking via Website" << endl;

cout << "Please choose your booking category:" << endl;

cout << "1. Book Only Ground (50,000 PKR per day)" << endl;

cout << "2. Book Ground + Seats (80,000 PKR per day)" << endl;

cout << "3. Book Ground + Seats + Stalls (80,000 PKR per day + 5,000
PKR per stall)" << endl;
while (true) {

cout << "Enter your choice (1-3): ";

cin >> subChoice;

if (cin.fail() || subChoice < 1 || subChoice > 3) {

cout << "Invalid choice. Please enter a valid option (1-3)." << endl;

cin.clear();

cin.ignore(numeric_limits<streamsize>::max(), '\n');

else {

break;

cout << "Enter the number of days you want to book: ";

cin >> days;

if (cin.fail() || days < 1) {

cout << "Invalid input. Please enter a positive number of days." <<
endl;

cin.clear();

cin.ignore(numeric_limits<streamsize>::max(), '\n');

return;

if (subChoice == 1) {

cout << "You have chosen to book only the ground." << endl;
total = groundRate * days;

else if (subChoice == 2) {

cout << "You have chosen to book the ground with seats." << endl;

total = (groundRate + seatsRate) * days;

else if (subChoice == 3) {

cout << "You have chosen to book the ground with seats and stalls."
<< endl;

cout << "Enter the number of stalls: ";

cin >> numStalls;

total = (groundRate + seatsRate + (numStalls * stallRate)) * days;

getDetails(user);

paymentDetails(user, total);

// _____________________________________

void privateBooking() {

int choice;

UserDetails user;

cout << "Welcome to OPTIMA ENDURANCE Booking System!" << endl;


while (true) {

cout << "Please choose your booking method:" << endl;

cout << "1. Call" << endl;

cout << "2. Office Visit" << endl;

cout << "3. Website" << endl;

cout << "Enter your choice (1-3): ";

cin >> choice;

if (cin.fail() || choice < 1 || choice > 3) {

cout << "Invalid choice. Please enter a valid option (1-3)." << endl;

cin.clear();

cin.ignore(numeric_limits<streamsize>::max(), '\n');

else {

break;

if (choice == 1) {

bookByCall();

else if (choice == 2) {

bookByVisit();

else if (choice == 3) {

bookByWebsite();

}
}

// _____________________________________

void showAdvertisementOptions() {

int selection = 0;

double totalAmount = 0;

const double prices[7] = {60.0, 70.0, 100.0, 120.0, 200.0, 50.0, 80.0};

const string adTypes[7] = {

"Boundary Rope Ad",

"Boundary Fence Ad",

"Over Break Ad",

"Score Board Ad",

"Fled Light Ad",

"Banners Ad",

"Premium Banners Ad (Second Floor)"

};

bool selectedAds[7] = {false, false, false, false, false, false, false};

while (true) {

clearScreen();
cout << "\nSelect an Advertisement Type (or type 8 to confirm):\n";

cout << left << setw(3) << "No" << setw(30) << "Advertisement
Type" << setw(15) << "Price ($)" << endl;

cout << "--------------------------------------------" << endl;

for (int i = 0; i < 7; ++i) {

cout << left << setw(3) << (i + 1)

<< setw(30) << adTypes[i]

<< setw(15) << prices[i]

<< (selectedAds[i] ? "\033[32m<Selected>\033[0m" : "")

<< endl;

cout << "\n8. Confirm\n";

cout << "Enter your choice (1-8): ";

cin >> selection;

if (selection >= 1 && selection <= 7) {

if (!selectedAds[selection - 1]) {

selectedAds[selection - 1] = true;

cout << "You selected option " << selection << ".\n";

} else {

cout << "Option " << selection << " is already selected.\n";

} else if (selection == 8) {

break;

} else {
cout << "Invalid choice. Please select again.\n";

continue;

clearScreen();

cout << "\nYour selected options are:\n";

cout << left << setw(3) << "No" << setw(30) << "Advertisement Type"
<< setw(15) << "Price ($)" << endl;

cout << "--------------------------------------------" << endl;

for (int i = 0; i < 7; ++i) {

if (selectedAds[i]) {

cout << left << setw(3) << (i + 1)

<< setw(30) << adTypes[i]

<< setw(15) << prices[i]

<< endl;

totalAmount += prices[i];

cout << "\nYour total amount is: $" << totalAmount << endl;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy