yurckk 0 Report post Posted October 23, 2008 (edited) assalamualaikum / salam sejahtera,kt aku ade prog C++ yg telah siap cuma nk convertkn jd C sahaja.ade sp2 berminat? sila PM aku A.S.A.P.Due date : 30 OKT 2008.Project student je.Tajuk : Sistem Tiket Panggung WayangP/S: bukan prog aku, tp ade org suruh aku outsource kn. so bnde ne urgent, nk cpt.aku tarok spoiler kt bwh ne, so sp agak2 leh tlg convertkn PM aku, pembayaran kte deal masa PM.klik spoiler utk tgk program: Spoiler : #include <iostream>#include <fstream>#include <iomanip>#include <string> const int size = 1000;using namespace std;int main();class Cinema{ public: void viewTime(); int selectCinema(); void bookTicket(int CinemaType, int CinematNo,int cust); int seatDisp(int FlightNo); int findRecord(int FlightNo); Cinema() { int a,b,c; for(c=0;c<4;c++) // represents the flight number { for(a=0;a<6;a++) // represents row { for(b=0;b<10;b++) // represents column { CinemaSeatNo[a][c] = 0; } } } } private: int CinemaSeatNo[6][10][4]; int CinemaType; int CinemaNo; int totalTicBook; int cust;}; class customer:public Cinema{ public: void addCustomer(); void dispCustomer(); private: char name; char address; char telNo; int payment;};char CinemaName[15]= { "Ada Apa Dengan Cinta","I'm not Single", "A lot Like Love","Senario The Movie", "Norbit","Anak Mami The Movie", "War of The World","The Matrix", "Mr. and Mrs. Smith","Popeye", "Kungu Panda","Lion King", "Jangan Pandang Belakang","Dorm", "Dark Water" };//------------------------------View Time---------------------------------------void viewTime(){ int menu=1; int pilihan; system("cls"); printf ( "\n\t^^^^^^^^^^^^^^^^^^^^ Available Movies ^^^^^^^^^^^^^^^^^\n" ); printf ( "\n\n\t\t 1.Romance Love\n" ); printf ( "\t\t 2.Comedy \n" ); printf ( "\t\t 3.Fighting \n" ); printf ( "\t\t 4.Cartoon \n" ); printf ( "\t\t 5.Horror \n" ); printf ( "\n\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" ); printf ( "\n\tEnter 0 to Exit this menu : " ); scanf ( pilihan ); while (pilihan != 0) { switch (pilihan) { case 1: printf("\n\n\t\tRomance Love\n\n"); printf("\t1.Ada Apa Dengan Cinta\n\n"); printf("\t2.I'm not Single\n\n"); printf("\t3.A lot Like Love\n\n"); break; case 2: printf("\n\n\t\tComedy\n\n"); printf("\t1.Senario The Movie\n\n"); printf("\t2.Norbit\n\n"); printf("\t3.Anak Mami The Movie\n\n"); break; case 3: printf("\n\n\t\tFighting\n\n"); printf("\t1.War of The World\n\n"); printf("\t2.The Matrix\n\n"); printf("\t3.Mr. and Mrs. Smith\n\n"); break; case 4: printf("\n\n\t\tCartoon\n\n"); printf("\t1.Popeye\n\n"); printf("\t2.Kungu Panda\n\n"); printf("\t3.Lion King\n\n"); break; case 5: printf("\n\n\t\tHorror\n\n"); printf("\t1.Jangan Pandang Belakang\n\n"); printf("\t2.Dorm\n\n"); printf("\t3.Dark Water\n\n"); break; default: scanf("\n\n\t\tInvalid choice\n\n"); break; } /* end switch case */ printf ( "\n\t^^^^^^^^^^^^^^^^^^^^ Available Movies ^^^^^^^^^^^^^^^^^\n" ); printf ( "\n\n\t\t 1.Romance Love\n" ); printf ( "\t\t 2.Comedy \n" ); printf ( "\t\t 3.Fighting \n" ); printf ( "\t\t 4.Cartoon \n" ); printf ( "\t\t 5.Horror \n" ); printf ( "\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" ); printf ( "\n\tEnter 0 to Exit this menu : " ); scanf ( pilihan ); } /* end while loop*/ system("cls");}// --------------------------------insert cinema reservation---------------------------------int Cinema::selectCinema(){ int menu1=0,menu2=0, select(void), CinemaNo; // cinemaSeatNo[a][x] system("cls"); do { printf("\n\t*************** Please Enter Reservation Detail. ***************") ("\n\nEnter Time Of Cinema..") ("\n\t[1] : For Morning Cinema") // cinemaSeatNo[x][x][0 to 1] ("\n\t[2] : For Afternoon Cinema") // cinemaSeatNo[x][x][2 to 3] ("\n\t[3] : For MidNight Cinema") // cinemaSeatNo[x][x][4 to 5] ("\n\t[0] : To Quit From Reservation Menu\nEnter choice: "); scanf( CinemaType ); // ------Check Type Of Cinema------ switch(CinemaType) { case 1: // Morning Cinema Selection do { printf("\n--- Morning Show Ticket Reservation ---") ("\n\n\t\tRomance Love\t\t\tCartoon\n") ("\t1.Ada Apa Dengan Cinta\t\t10.Popeye\n") ("\t2.I'm not Single\t\t11.Kungu Panda\n") ("\t3.A lot Like Love\t\t12.Lion King\n") ("\n\t\tComedy\t\t\tHorror\n") ("\t4.Senario The Movie\t\t13.Jangan Pandang Belakang\n") ("\t5.Norbit\t\t\t14.Dorm\n") ("\t6.Anak Mami The Movie\t\t15.Dark Water\n") ("\n\t\tFighting\n") ("\t7.War of The World\n") ("\t8.The Matrix\n") ("\t9.Mr. and Mrs. Smith\n") ("\n\tPlease Select a Movie : "); scanf(CinemaNo); if(CinemaNo>0&&CinemaNo<16){ CinemaNo=CinemaNo-1; cust=seatDisp(CinemaNo); bookTicket(CinemaType,CinemaNo,cust); menu2=1; menu1=2; break; } else if(CinemaNo==0)menu2=1; else{ cerr << "Invalid choice"<<endl<<endl; system ("pause"); system("cls"); } }while(menu2 !=1); break; case 2: // Afternoon Cinema Selection do{ printf("\n--- Afternoon Show Ticket Reservation ---") ("\n\n\t\tRomance Love\t\t\tCartoon\n") ("\t1.Ada Apa Dengan Cinta\t\t10.Popeye\n") ("\t2.I'm not Single\t\t11.Kungu Panda\n") ("\t3.A lot Like Love\t\t12.Lion King\n") ("\n\t\tComedy\t\t\tHorror\n") ("\t4.Senario The Movie\t\t13.Jangan Pandang Belakang\n") ("\t5.Norbit\t\t\t14.Dorm\n") ("\t6.Anak Mami The Movie\t\t15.Dark Water\n") ("\n\t\tFighting\n") ("\t7.War of The World\n") ("\t8.The Matrix\n") ("\t9.Mr. and Mrs. Smith\n") ("\n\tPlease Select a Movie : "); scanf(CinemaNo); if(CinemaNo>0&&CinemaNo<16){ CinemaNo=CinemaNo-1; cust=seatDisp(CinemaNo); bookTicket(CinemaType,CinemaNo,cust); menu2=1; menu1=2; break; } else if(CinemaNo==0)menu2=1; else{ cerr << "Invalid choice"<<endl<<endl; system ("pause"); system("cls"); } }while(menu2 !=1); break; case 3: // Night Cinema Selection do{ printf("\n--- Midnight Show Ticket Reservation ---") ("\n\n\t\tRomance Love\t\t\tCartoon\n") ("\t1.Ada Apa Dengan Cinta\t\t10.Popeye\n") ("\t2.I'm not Single\t\t11.Kungu Panda\n") ("\t3.A lot Like Love\t\t12.Lion King\n") ("\n\t\tComedy\t\t\tHorror\n") ("\t4.Senario The Movie\t\t13.Jangan Pandang Belakang\n") ("\t5.Norbit\t\t\t14.Dorm\n") ("\t6.Anak Mami The Movie\t\t15.Dark Water\n") ("\n\t\tFighting\n") ("\t7.War of The World\n") ("\t8.The Matrix\n") ("\t9.Mr. and Mrs. Smith\n") ("\n\tPlease Select a Movie : "); scanf(CinemaNo); if(CinemaNo>0&&CinemaNo<16){ CinemaNo=CinemaNo-1; cust=seatDisp(CinemaNo); bookTicket(CinemaType,CinemaNo,cust); menu2=1; menu1=2; break; } else if(CinemaNo==0)menu2=1; else{ cerr << "Invalid choice"<<endl<<endl; system ("pause"); system("cls"); } }while(menu2 !=1); break; case 0: menu1=1; break; default: cerr << "Invalid choice"<<endl<<endl; system ("pause"); system("cls"); } }while (menu1 ==0);return (menu1);}// -------------------------------- booking ticket function --------------------------------void Cinema::bookTicket(int CinemaType, int CinemaNo, int customer){ int seatNo, seatCheck=0, temp, a, b, p; string FType; p=60-cust; printf("\nHow Many Ticket Do You Want?[ticket available:("<<p<<")]: "); scanf(totalTicBook); if (totalTicBook>p||totalTicBook<1) { do { printf("\nSorry!! Seat Available Not Enough Or Invalid Input..."); printf("\nHow Many Ticket Do You Want?[ticket available:("<<p<<")]: "); scanf(totalTicBook); }while(totalTicBook>p||totalTicBook<1); } for (int i=1;i<=totalTicBook;i++) { system("cls"); seatDisp(CinemaNo); printf("\nBooking["<<i<<"/"<<totalTicBook<<"]."<<"\nEnter The Seat Number(1 to 60): "); scanf(seatNo); if (seatNo<=10) // Ticket between 1 to 10 { a=0; b=seatNo-1; if (CinemaSeatNo[a][CinemaNo]==1) { seatCheck=1; i--; printf("\nSorry...Ticket# "<<seatNo<<" booked!!\n"); system("pause"); } else { seatCheck=0; CinemaSeatNo[a][CinemaNo]=1; } } else if (seatNo>10&&seatNo<=20) // Ticket between 11 to 20 { a=1; b=seatNo-11; if (CinemaSeatNo[a][CinemaNo]==1) { seatCheck=1; i--; printf("\nSorry...Ticket# "<<seatNo<<" booked!!\n"); system("pause"); } else { seatCheck=0; CinemaSeatNo[a][CinemaNo]=1; } } else if (seatNo>20&&seatNo<=30) // Ticket between 21 to 30 { a=2; b=seatNo-21; if (CinemaSeatNo[a][CinemaNo]==1) { seatCheck=1; i--; printf("\nSorry...Ticket# "<<seatNo<<" booked!!\n"); system("pause"); } else { seatCheck=0; CinemaSeatNo[a][CinemaNo]=1; } } else if (seatNo>30&&seatNo<=40) // Ticket between 31 to 40 { a=3; b=seatNo-31; if (CinemaSeatNo[a][CinemaNo]==1) { seatCheck=1; i--; printf("\nSorry...Ticket# "<<seatNo<<" booked!!\n"); system("pause"); } else { seatCheck=0; CinemaSeatNo[a][CinemaNo]=1; } } else if (seatNo>40&&seatNo<=50) // Ticket between 41 to 50 { a=4; b=seatNo-41; if (CinemaSeatNo[a][CinemaNo]==1) { seatCheck=1; i--; printf("\nSorry...Ticket# "<<seatNo<<" booked!!\n"); system("pause"); } else { seatCheck=0; CinemaSeatNo[a][CinemaNo]=1; } } else if (seatNo>50&&seatNo<=60) // Ticket between 51 to 60 { a=5; b=seatNo-51; if (CinemaSeatNo[a][CinemaNo]==1) { seatCheck=1; i--; printf("\nSorry...Ticket# "<<seatNo<<" booked!!\n"); system("pause"); } else { seatCheck=0; CinemaSeatNo[a][CinemaNo]=1; } } // ------------- saving cinemaseat -------------- if (CinemaNo==0&&seatCheck==0) { ofstream fileout("Cinema1",ios::out|ios::binary); for(a=0;a<6;a++) // represents row { for(b=0;b<10;b++) // represents column { temp=CinemaSeatNo[a][CinemaNo]; fileout<<temp<<" "; } } } else if (CinemaNo==1&&seatCheck==0) { ofstream fileout("Cinema2",ios::out|ios::binary); for(a=0;a<6;a++) // represents row { for(b=0;b<10;b++) // represents column { temp=CinemaSeatNo[a][CinemaNo]; fileout<<temp<<" "; } } } else if (CinemaNo==2&&seatCheck==0) { ofstream fileout("Cinema",ios::out|ios::binary); for(a=0;a<6;a++) // represents row { for(b=0;b<10;b++) // represents column { temp=CinemaSeatNo[a][CinemaNo]; fileout<<temp<<" "; } } } } system("cls"); seatDisp(CinemaNo);// -------------saving customer data-------------- char CinemaTypeChr[3]={"Morning","Afternoon","Night"}; ofstream fout("customer",ios::out|ios::app|ios::binary); fout<<"Cinema : "<<CinemaTypeChr[CinemaType-1]<<" - "<<CinemaName[CinemaNo]<<endl<<"Total ticket(s) Booked: "<<totalTicBook<<endl;}//-------------------------------Find Record----------------------------------------int Cinema::findRecord(int CinemaNo){ int a,b,temp; cust=0; if (CinemaNo==0) { ifstream fin("Cinema1",ios::in|ios::binary); while (fin) { for(a=0;a<6;a++) // represents row { for(b=0;b<10;b++) // represents column { fin>>temp; if (!fin.fail())// avoid displaying the last char twice CinemaSeatNo[a][CinemaNo] = temp; if (temp==1) cust++; } } } } if (CinemaNo==1) { ifstream fin("Cinema2",ios::in|ios::binary); while (fin) { for(a=0;a<6;a++) // represents row { for(b=0;b<10;b++) // represents column { fin>>temp; if (!fin.fail())// avoid displaying the last char twice CinemaSeatNo[a][CinemaNo] = temp; if (temp==1) cust++; } } } } if (CinemaNo==2) { ifstream fin("Cinema3",ios::in|ios::binary); while (fin) { for(a=0;a<6;a++) // represents row { for(b=0;b<10;b++) // represents column { fin>>temp; if (!fin.fail())// avoid displaying the last char twice CinemaSeatNo[a][CinemaNo] = temp; if (temp==1) cust++; } } } } if (CinemaNo==3) { ifstream fin("flight4",ios::in|ios::binary); while (fin) { for(a=0;a<6;a++) // represents row { for(b=0;b<10;b++) // represents column { fin>>temp; if (!fin.fail())// avoid displaying the last char twice CinemaSeatNo[a][CinemaNo] = temp; if (temp==1) cust++; } } } }// ---- statement to solve the counting of customer ---- if (cust>60) cust = cust-60; return (cust);}void customer::addCustomer(){ string P; cin.ignore(size,'\n'); printf("\nEnter Customer Name: "); cin.getline(name,size); printf("Enter Customer Address: "); cin.getline(address,size); printf("Enter Customer Contact Number(enter N/A if no contact no.): "); cin.getline(telNo,size); printf("Enter Type Of Payment") ("\n[1] : Cash") ("\n[2] : Credit Card\nChoice: "); scanf(payment);// ----------- saving customer details ----------- if (payment==1) P="CASH"; if (payment==2) P="CREDIT CARD"; ofstream fout("customer",ios::out|ios::app|ios::binary); fout<<"Customer Name: "<<name<<endl<<"Customer Address: "<<address<<endl <<"Customer Contact Number: "<<telNo<<endl<<" Type Of Payment: "<<P<<endl<<endl; printf("\nBooking Process Is Done..\n"); system("pause"); system("cls");} // ------------------Displaying available seat[0] or booked seat[1] -------------------int Cinema::seatDisp(int CinemaNo){ char Title; strcpy(Title,CinemaName[CinemaNo]); cust=Cinema::findRecord(CinemaNo); system("cls"); printf ( "\n\n\tDisplaying Seat For " , Title); printf ( "\n\t--------------------------------------------------------------------\n"); for(int a=0;a<6;a++) { printf("\t"); for(int b=0;b<10;b++) { if(CinemaSeatNo[a][CinemaNo]==0) { if (a==0) printf(setw(2)<<b+1("[0] "); else if (a==1) printf(b+11("[0] "); else if (a==2) printf(b+21<<("[0] "); else if (a==3) printf(b+31("[0] "); else if (a==4) printf(b+41("[0] "); else if (a==5) printf(b+51("[0] "); } else if(CinemaSeatNo[a][CinemaNo]==1) { if (a==0) printf(setw(2)<<b+1("[1] "); else if (a==1) printf(b+11("[1] "); else if (a==2) printf(b+21("[1] "); else if (a==3) printf(b+31("[1] "); else if (a==4) printf(b+41("[1] "); else if (a==5) printf(b+51("[1] "); } } printf("\n\n"); } printf("\t--------------------------------------------------------------------") ("\n\tTotal Booked Seat: ",cust); return (cust);}//------------------ Display/View Customer -----------------------void customer::dispCustomer(){ char ch; system("cls"); ifstream fin("customer",ios::in|ios::binary); printf("\n\t******************* Customer Details.. *******************\n\n\n"); if(!fin) { cerr<<"\nError opening the file..!!\n"; } while(fin) { fin.get(ch); if (!fin.fail()) // avoid displaying the last char twice printf(ch); } system("pause"); system("cls");} int main(){ int choice,seatchoice; int menu=0; int CinemaMenu=0; int cinMenu = 0; int i; Cinema F; customer C; system("cls"); printf ( "\t*****************************************************\n" ); printf ( "\t* *\n" ); printf ( "\t* Welcome To *\n" ); printf ( "\t* __CINEMA BOOKING ONLINE__ *\n" ); printf ( "\t* *\n" ); printf ( "\t*****************************************************\n" ); do { printf ( "\n\n\t^^^^^^^^^^^^^^^^^^^^^ MAIN MENU ^^^^^^^^^^^^^^^^^^^^^\n\n" ); printf ( "\t1. View Available Cinema\n" ); printf ( "\t2. Check Available Seats\n" ); printf ( "\t3. Book Ticket(s)\n" ); printf ( "\t4. View Customer Bookings\n\n" ); printf ( "\t0. Quit From System\n" ); printf ( "\n\n\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" ); printf ( "\n\n\tEnter your option : " ); scanf (choice); switch(choice) { case 1: viewTime(); break; case 2: system("cls"); do { printf( "\n\t^^^^^^^^^^^^^^^^^^^^^ AVAILABLE SEATS ^^^^^^^^^^^^^^^^^^^^^^^^^\n\n" ); for(i=0;i<15;i++){ printf( "\t"<<i+1<<". Available Seat "<<CinemaName<<"\n" ); } printf( "\t0. To Quit From Available Seats Menu\n" ) ( "\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n)" ( "\tEnter Your Option : "); scanf(seatchoice); if(seatchoice>0&&seatchoice<15) F.seatDisp(seatchoice-1); else if(seatchoice==0){ cinMenu=1; system("cls"); } else{ cerr << "Invalid choice" << endl << endl; system ("pause"); } }while(cinMenu !=1); break; case 3: if (C.selectCinema()==2) C.addCustomer(); break; case 4: C.dispCustomer(); break; case 0: menu = 1; system ("cls"); printf ( "\n\t__________________________________________________________________\n\n\n"); printf ( "\t Thank you for using CINEMA BOOKING ONLINE System ... \n\n"); printf ( "\n\t__________________________________________________________________\n\n"); break; default: cerr << "Invalid choice" << endl << endl; system ("pause"); system("cls"); } }while (menu !=1); system ("pause"); return 0;} Edited October 23, 2008 by yurckk Share this post Link to post Share on other sites
yurckk 0 Report post Posted November 5, 2008 ok, kt cne dah tutup da bid. xde sp bid tp xpe. dah setel gak. btw aku close thread ni, nk sp2 nk rujukan utk "system wayang" utk C++. Just bukak spoiler tu. Share this post Link to post Share on other sites