Untitled
unknown
plain_text
a year ago
5.6 kB
0
Indexable
Never
#include <stdio.h> #include <string.h> #define max_tickets 5 #define max_event 10 #define max_customers 10 typedef struct{ int event_id; char event_title [50]; char event_artist[50]; char event_date[50]; char event_time[20]; int ticket_price; int event_stock; }event; typedef struct{ char name [50]; int ticket_bought[max_tickets]; int total_cost; }customer; void add_event(event *pangyayari, int i){ int j, numbers[11]; int id; char title[50], artist[50], date[50], time[50]; int price, stock; printf("========Adding event========\n"); printf("*note: you need to type numbers only\n"); //array[index].elemname = value printf("Enter your event ID: "); scanf("%d", &id); pangyayari[i].event_id = id; printf("Your event title is:"); scanf("%s", title); strcpy(pangyayari[i].event_title, title); printf("Artist of the event: "); scanf("%s", artist); strcpy(pangyayari[i].event_artist, artist); printf("Date of event: "); scanf("%s", date); strcpy(pangyayari[i].event_date, date); printf("Time of event: "); scanf("%s", time); strcpy(pangyayari[i].event_time, time); printf("Enter Price: "); scanf("%d", &price); pangyayari[i].ticket_price = price; printf("Enter Stock:"); scanf("%d", &stock); pangyayari[i].event_stock = stock; } //void find_event_id(event *pangyayari, event_id){ //} void buy_ticket(customer *person, event *pangyayari, int num_of_events){ int j; printf("Enter your name: "); scanf("%s", ask_name); //needs icompare if existing yung name for(int i = 0; i < num_of_events; i++){ person[i].name } if (strcmp(ask_name, customer[i].name)== 0){ //if it exists //continue access the info of the customer } //tickets available //else if the customer is not in the system //making an customer info else{ strcpy(person.name[i], ask_name); } printf("========EVENTS AVAILABLE========\n"); for (j=0; j<num_of_events; j++){ printf("[%d] %s %s", j, pangyayari[j].event_title, pangyayari[j].event_artist); } int event_id; while(1){ printf("Enter event id to buy:"); scanf("%d", &event_id); //if wala yung event id sa array //invalid inpuut //if (event_id != pangyayari[i].event_id){ //} } } int id_checker(event *pangyayari, int ask_id, int num_of_events){ //checker for(int i=0; i<num_of_events; i++){ if(pangyayari[i].event_id == ask_id){ return i; } } return -1; } void edit_event(event *pangyayari, int num_of_events){ for(int i = 0; i < num_of_events; i++){ printf("[%d] %s %s\n", i, pangyayari[i].event_title, pangyayari[i].event_artist); } int choice; printf("Enter index:"); scanf("%d", &choice); printf("Enter new date:"); scanf("%s", pangyayari[choice].event_date); printf("Enter new time:"); scanf("%s", pangyayari[choice].event_time); printf("Enter new price:"); scanf("%d", &pangyayari[choice].ticket_price); printf("Enter new stock:"); scanf("%d", &pangyayari[choice].event_stock); } void view_all_events(event *pangyayari, int num_of_events){ printf("All Events:\n"); for(int i = 0; i < num_of_events; i++){ printf("Event ID: %d\n", pangyayari[i].event_id); printf("Event Title: %s\n", pangyayari[i].event_title); printf("Artist: %s\n", pangyayari[i].event_artist); printf("Date: %s\n", pangyayari[i].event_date); printf("Time: %s\n", pangyayari[i].event_time); printf("Ticket: %d\n", pangyayari[i].ticket_price); printf("Stock: %d\n", pangyayari[i].event_stock); printf("\n"); } } int main(){ customer person[10]; event pangyayari[10]; int select_num, exit = 0, i = 0, ask_id, num_of_events = 0; char ask_name[50]; while(exit != 1){ printf("Welcome To Saaking Cinema\n"); printf("[1] Add Event Details\n"); printf("[2] Buy Ticket\n"); printf("[3] Edit Event Details\n"); printf("[4] Delete Event\n"); printf("[5] View All Events\n"); printf("[6] View All Customers\n"); printf("[7] Save event & customer information\n"); printf("[8] Load event & customer information\n" ); printf("[9] Mamba out/Exit\n"); printf("Please enter the number you want:\n"); scanf("%d", &select_num); switch(select_num){ case 1: add_event(pangyayari, i); i++; num_of_events++; printf("You've successfully added an event\n"); break; case 2: buy_ticket(person, pangyayari , i); break; case 3: //id checker edit_event(pangyayari, i); break; /*case 4: delete_event(); */ case 5 : view_all_events(pangyayari, i); break; /*case 6: view_all_customers(); case 7: save_event(); case 8 : load_event(); */ case 9 : exit = 1; printf("Bye bounce muna tayo uwu\n"); break; } } return 0; }