|
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
กระทู้ #1245 [อื่นๆ] (จาก IP: 124.157.236.98)
โปรแกรมจองตั๋วหนัง
พอดีผมจะทำโปรแกรมจองตั๋วหนังอ่ะคับ ต้องส่งอาจารย์ วานผู้รู้แนะนำแนวทาง หรือ source code ทีนะคับ ขอบคุณล่วงหน้าคับ
|
จากคุณ
:
mckatyd [2007-07-31 10:13:45]
|
|
ความคิดเห็น #26140 (จาก IP: 202.91.19.192)
ขอด้วยคนนะครับ ขอบคุณล่วงหน้าครับ |
จากคุณ
:
ลพัฒน์ จิตร์ฉลาด / rongjiee@hotmail.com [2007-10-09 21:50:09]
|
|
ความคิดเห็น #26318 (จาก IP: 125.24.214.147)
ขอด้วยคับ ต้องรีบส่งอาจารย์นะคับ ขอบคุณล่วงหน้าคับ |
จากคุณ
:
kamiru357 / denbrodium@hotmail.com [2007-12-05 21:27:23]
|
|
ความคิดเห็น #26404 (จาก IP: 203.113.67.69)
ด่วน! ขอโปรแกรมจองตั๋วหนังที่ใช้โปรแกรม vb ทำอ่าค่ะมีบ้างมั้ยเอ่ย ขอขอบคุณล่วงหน้าสำหรับผู้ที่มีนะค๊ะ |
จากคุณ
:
noo_nging / nging_yong@hotmail.com [2008-01-08 19:37:44]
|
|
ความคิดเห็น #26417 (จาก IP: 203.155.46.54)
หนูจะวิเคราะห์ระบบการใช้โปรแกรมจองตั๋วหนังโดยเริ่มแต่ การวางแผน วิเคราะห์ ออกบบ ขั้นตอนการทำงาน และการนำไปใช้ประโยชน์ ขอให้ช่วยบอกหนูหน่อยนะคะ เพราะไม่รุ้จะหามาจากไหน ขอบคุณคะ |
จากคุณ
:
ชญานันท์ อินทรคูสิน / mojiko_jj@hotmail.com [2008-01-13 12:07:28]
|
|
ความคิดเห็น #26554 (จาก IP: 61.7.183.241)
ขอด้วยคับ เเต่ เป็น java คับ |
จากคุณ
:
นนทชาติ / tae_mill@hotmail.com [2008-02-20 17:31:22]
|
|
ความคิดเห็น #27046 (จาก IP: 202.28.35.3)
จะทำงานส่งอาจารย์นะค่ะทำเป็นเขียนโปรแกรมจองตั๋วหนังอยากได้โค้ด |
จากคุณ
:
มิ้น / thippayaratbc505@hotmail.com [2008-09-04 17:24:40]
|
|
ความคิดเห็น #27063 (จาก IP: 61.19.144.194)
ขอความกรุณาด้วยนะครับ รบกวนช่วยหน่อยนะคับ ผมขอด้วยคนนะคับ เพราะผมไม่รู้จะทำอย่างไรแล้ว |
จากคุณ
:
aof / peekung_17_casper@hotmail.com [2008-09-09 15:51:52]
|
|
ความคิดเห็น #27064 (จาก IP: 202.69.139.194)
อยากได้เหมือนกันคับผม ขอความกรุณาด้วยนะคับ |
จากคุณ
:
aof / peekung_17_casper@hotmail.com [2008-09-09 15:55:44]
|
|
ความคิดเห็น #27255 (จาก IP: 58.136.22.149)
หนูอยากเห็นตัวอย่างโปรแกรมจองตั๋วหนังหน่อยค่ะ หนูไม่มีแบบ Visual Studio 2005 ขอบคุนนะค่ะ |
จากคุณ
:
เอ / A_49011120@hotmail.com [2008-12-21 18:41:31]
|
|
ความคิดเห็น #27540 (จาก IP: 202.29.20.105)
ผมจะทำโปรเจ๊กจบเกี่ยวการจองตั๋วหนังนะ แต่ยังไม่ส่งรูปเล่มเลยใครมีช่วยส่งต่อให้ผม บ้างนะวานล่ะครับ |
จากคุณ
:
ป๊อปอาย / thanapan_popeye@hotmail.com [2009-08-24 14:42:05]
|
|
ความคิดเห็น #27547 (จาก IP: 125.24.131.47)
ทำโปรเจคจบ แล้วมาของานคนอื่นไปส่ง ขี้เกียจไปหน่อยไหม๊ |
จากคุณ
:
น่าอาย [2009-08-24 21:24:40]
|
|
ความคิดเห็น #27773 (จาก IP: 125.27.170.224)
หนูจะทำโปรเจค จองตั๋วหนัง แต่ยังไม่รู้ว่าจะทำฐานข้อมูลยังไง ถ้าใครมี ซอสโค้ด กรุณา<br>ส่งมาเป็นตัวอย่างให้ดูมั่งนะคะ ขอบคุนค่า |
จากคุณ
:
หมิว / kanokwan_2.1@hotmail.com [2010-02-07 18:25:45]
|
|
ความคิดเห็น #27917 (จาก IP: 124.122.45.2)
ขอโปรแกรมจองตั๋วหนังที่ใช้โปรแกรม vb ทำอ่าค่ะมีบ้างมั้ยเอ่ย ขอขอบคุณล่วงหน้าสำหรับผู้ที่มีนะค๊ะ |
จากคุณ
:
แยม / yam.jam@hotmail.com [2010-06-18 10:02:37]
|
|
ความคิดเห็น #28024 (จาก IP: 180.183.51.235)
ขอด้วยครับ |
จากคุณ
:
surawut / surawut_srivised@hotmail.com [2010-09-25 00:36:14]
|
|
ความคิดเห็น #28025 (จาก IP: 180.183.51.235)
ขอด้วยครับ |
จากคุณ
:
surawut / surawut_srivised@hotmail.com [2010-09-25 00:36:40]
|
|
ความคิดเห็น #29000 (จาก IP: 113.53.205.174)
หนูจะวิเคราะห์ระบบการใช้โปรแกรมจองตั๋วหนังโดยเริ่มแต่ การวางแผน วิเคราะห์ ออกบบ ขั้นตอนการทำงาน และการนำไปใช้ประโยชน์ ขอให้ช่วยบอกหนูหน่อยนะคะ เพราะไม่รุ้จะหามาจากไหน ขอบคุณคะ |
จากคุณ
:
ann nana / namam_ann@hotmail.com [2014-02-01 12:40:43]
|
|
ความคิดเห็น #29011 (จาก IP: 115.67.135.74)
ขอด้วยคนนะครับ คือผมเอามาศึกษาในโปรเจ็คครับ |
จากคุณ
:
piyaphon / piyaphon.ph.pp@gmail.com [2014-02-23 11:30:03]
|
|
ความคิดเห็น #29212 (จาก IP: 1.1.144.205)
ดูยัง ไง หรอ ครับ บ บ |
จากคุณ
:
Arnuphap Sabpaso [2015-03-05 20:43:35]
|
|
ความคิดเห็น #29231 (จาก IP: 49.49.80.167)
โปรแกรมจองตั๋วหนัง
ที่มาของโปรแกรมนี้ : https://compilr.com/thunderstorm/movie- ... Ticket.cpp
#include <iostream> #include <fstream> #include <iomanip> #include <string>
const int size = 300; 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][b][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[size]; char address[size]; char telNo[size]; int payment; }; //------------------------------View Time--------------------------------------- void viewTime() { int menu=1; int back; system("cls"); cout << "\n\t^^^^^^^^^^^^^^^^^^^^ Available Cinema ^^^^^^^^^^^^^^^^^\n"; cout << "\n\n\t\t 1.Pirates Of The Carribean 4\n"; cout << "\t\t 2.Die Hard 4.0 \n"; cout << "\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"; cout << "\n\tEnter 0 to Exit From This Menu : "; cin >> back;
system("cls"); } // --------------------------------insert cinema data--------------------------------- int Cinema::selectCinema() { int menu1=0,menu2=0, CinemaNo; // cinemaSeatNo[a][b][x] system("cls"); do { cout<<"\n\t************* Please Enter Reservation Detail. *************" <<"\n\nEnter Time Of Cinema.." <<"\n\t[1] : For Afernoon Cinema" // cinemaSeatNo[x][x][0 to 1] <<"\n\t[2] : For MidNight Cinema" // cinemaSeatNo[x][x][2 to 3] <<"\n\t[0] : To Quit From Reservation Menu\nEnter choice: "; cin>>CinemaType; // 1= Pirates Of The Carribean 2, 2=tipah tertipu // ------Check Type Of Cinema------ switch(CinemaType) { case 1: do{ cout<<"\n--- Afternoon Show Ticket Reservation -" <<"\nEnter Cinema.." <<"\n\t[1] For Pirates Of The Carribean 4" <<"\n\t[2] For Die Hard 4.0" <<"\n\t[0] For Quit Menu\nEnter choice: "; cin>>CinemaNo; switch(CinemaNo) { case 1: case 2: case 3: CinemaNo=CinemaNo-1; cust=seatDisp(CinemaNo); bookTicket(CinemaType,CinemaNo,cust); menu2=1; menu1=2; break; case 0: menu2=1; break; default: cerr << "Invalid choice"<<endl<<endl; system ("pause"); system("cls"); } }while(menu2 !=1); break;
case 2: do{ cout<<"\n--- Night Show Ticket Reservation -" <<"\nEnter Flight.." <<"\n\t[4] For Pirates Of The Carribean 4" <<"\n\t[5] For Die Hard 4.0" <<"\n\t[0] For Quit Menu\nEnter choice: "; cin>>CinemaNo; switch(CinemaNo) { case 4: case 5: case 6: CinemaNo=CinemaNo-1; cust=seatDisp(CinemaNo); bookTicket(CinemaType,CinemaNo,cust); menu2=1; menu1=2; break; case 0: menu2=1; break; default: 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; cout<<"\nHow Many Ticket Do You Want?[ticket available:("<<p<<")]: "; cin>>totalTicBook; if (totalTicBook>p||totalTicBook<1) { do { cout<<"\nSorry!! Seat Available Not Enough Or Invalid Input..."; cout<<"\nHow Many Ticket Do You Want?[ticket available:("<<p<<")]: "; cin>>totalTicBook; }while(totalTicBook>p||totalTicBook<1); } for (int i=1;i<=totalTicBook;i++) { system("cls"); seatDisp(CinemaNo); cout<<"\nBooking["<<i<<"/"<<totalTicBook<<"]."<<"\nEnter The Seat Number(1 to 60): "; cin>>seatNo; if (seatNo<=10) // Ticket between 1 to 10 { a=0; b=seatNo-1; if (CinemaSeatNo[a][b][CinemaNo]==1) { seatCheck=1; i--; cout<<"\nSorry...Ticket# "<<seatNo<<" booked!!\n"; system("pause"); } else { seatCheck=0; CinemaSeatNo[a][b][CinemaNo]=1; } } else if (seatNo>10&&seatNo<=20) // Ticket between 11 to 20 { a=1; b=seatNo-11; if (CinemaSeatNo[a][b][CinemaNo]==1) { seatCheck=1; i--; cout<<"\nSorry...Ticket# "<<seatNo<<" booked!!\n"; system("pause"); } else { seatCheck=0; CinemaSeatNo[a][b][CinemaNo]=1; } } else if (seatNo>20&&seatNo<=30) // Ticket between 21 to 30 { a=2; b=seatNo-21; if (CinemaSeatNo[a][b][CinemaNo]==1) { seatCheck=1; i--; cout<<"\nSorry...Ticket# "<<seatNo<<" booked!!\n"; system("pause"); } else { seatCheck=0; CinemaSeatNo[a][b][CinemaNo]=1; } } else if (seatNo>30&&seatNo<=40) // Ticket between 31 to 40 { a=3; b=seatNo-31; if (CinemaSeatNo[a][b][CinemaNo]==1) { seatCheck=1; i--; cout<<"\nSorry...Ticket# "<<seatNo<<" booked!!\n"; system("pause"); } else { seatCheck=0; CinemaSeatNo[a][b][CinemaNo]=1; } } else if (seatNo>40&&seatNo<=50) // Ticket between 41 to 50 { a=4; b=seatNo-41; if (CinemaSeatNo[a][b][CinemaNo]==1) { seatCheck=1; i--; cout<<"\nSorry...Ticket# "<<seatNo<<" booked!!\n"; system("pause"); } else { seatCheck=0; CinemaSeatNo[a][b][CinemaNo]=1; } } else if (seatNo>50&&seatNo<=60) // Ticket between 51 to 60 { a=5; b=seatNo-51; if (CinemaSeatNo[a][b][CinemaNo]==1) { seatCheck=1; i--; cout<<"\nSorry...Ticket# "<<seatNo<<" booked!!\n"; system("pause"); } else { seatCheck=0; CinemaSeatNo[a][b][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][b][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][b][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][b][CinemaNo]; fileout<<temp<<" "; } } }
} system("cls"); seatDisp(CinemaNo); // -------------saving customer data-------------- if (CinemaType==1&&CinemaNo==0) FType="AfterNoon - Pirates Of the Carribean 4"; if (CinemaType==1&&CinemaNo==1) FType="AfterNoon - Die Hard 4.0"; if (CinemaType==2&&CinemaNo==3) FType="Night - Pirates Of The Carribean"; if (CinemaType==2&&CinemaNo==4) FType="Night - Die Hard 4.0"; ofstream fout("customer",ios::out|ios::app|ios::binary); fout<<"Cinema : "<<FType<<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][b][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][b][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][b][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][b][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'); cout<<"\nEnter Customer Name: "; cin.getline(name,size); cout<<"Enter Customer Address: "; cin.getline(address,size); cout<<"Enter Customer Contact Number(enter N/A if no contact no.): "; cin.getline(telNo,size); cout<<"Enter Type Of Payment" <<"\n[1] : Cash" <<"\n[2] : Credit Card\nChoice: "; cin>>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; cout<<"\nBooking Process Is Done..\n"; system("pause"); system("cls"); }
// ------------------Displaying available seat[0] or booked seat[1] ------------------- int Cinema::seatDisp(int CinemaNo) { string title; if (CinemaNo==0) title="Pirates Of The Carribean"; else if (CinemaNo==1) title="Die Hard"; cust=Cinema::findRecord(CinemaNo); cout << "\n\n\tDisplaying Seat For " << title; cout << "\n\t------------------------------------------------------------------\n"; for(int a=0;a<6;a++) { cout<<"\t"; for(int b=0;b<10;b++) { if(CinemaSeatNo[a][b][CinemaNo]==0) { if (a==0) cout<<setw(2)<<b+1<<"[0] "; else if (a==1) cout<<b+11<<"[0] "; else if (a==2) cout<<b+21<<"[0] "; else if (a==3) cout<<b+31<<"[0] "; else if (a==4) cout<<b+41<<"[0] "; else if (a==5) cout<<b+51<<"[0] "; } else if(CinemaSeatNo[a][b][CinemaNo]==1) { if (a==0) cout<<setw(2)<<b+1<<"[1] "; else if (a==1) cout<<b+11<<"[1] "; else if (a==2) cout<<b+21<<"[1] "; else if (a==3) cout<<b+31<<"[1] "; else if (a==4) cout<<b+41<<"[1] "; else if (a==5) cout<<b+51<<"[1] "; } } cout<<"\n\n"; } cout<<"\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); cout<<"\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 cout<<ch; } system("pause"); system("cls"); }
int main() { int choice,seatchoice; int menu=0; int CinemaMenu=0; int cinMenu = 0; Cinema F; customer C; system("cls"); cout << "\t***************************************************\n"; cout << "\t* *\n"; cout << "\t* Welcome To *\n"; cout << "\t* _Movie Ticket System_ *\n"; cout << "\t* *\n"; cout << "\t***************************************************\n"; do { cout << "\n\n\t^^^^^^^^^^^^^^^^^^^^^ MAIN MENU ^^^^^^^^^^^^^^^^^^^^^\n\n"; cout << "\t1. View Available Cinema\n"; cout << "\t2. Check Available Seats\n"; cout << "\t3. Book Ticket(s)\n"; cout << "\t4. View Customer Bookings\n\n"; cout << "\t0. Quit From System\n"; cout << "\n\n\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"; cout << "\n\n\tEnter your option : "; cin >> choice;
switch(choice) { case 1: viewTime(); break; case 2: system("cls"); do { cout<< "\n\t^^^^^^^^^^^^^^^^^^^^^ AVAILABLE SEATS ^^^^^^^^^^^^^^^^^^^^^^^^^\n\n" << "\t1. Available Seat For Pirates Of The Carribean\n" << "\t2. Available Seat For Die Hard 4.0\n" << "\t0. To Quit From Available Seats Menu\n" << "\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" << "\tEnter Your Option : "; cin>>seatchoice; switch(seatchoice) { case 1: F.seatDisp(seatchoice-1); break; case 2: F.seatDisp(seatchoice-1); break; case 3: F.seatDisp(seatchoice-1); break; case 4: F.seatDisp(seatchoice-1); break; case 0: cinMenu=1; system("cls"); break; default: 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"); cout << "\n\t__________________________________________________________________\n\n\n"; cout << "\t Thank you for using Movie Ticket System :) ... \n\n"; cout << "\n\t__________________________________________________________________\n\n"; break; default: cerr << "Invalid choice" << endl << endl; system ("pause"); system("cls"); } }while (menu !=1);
system ("pause"); return 0; } |
จากคุณ
:
นกแสก / kitsumato@yahoo.co.th [2015-05-01 11:56:58]
|
|
ความคิดเห็น #29448 (จาก IP: 182.232.83.68)
โปรแกรมจองตั๋วหนัง ภาษาจาวา
ที่มาของโค้ด : https://gist.github.com/parsons-Jsr/4043298#file-fulldatabasegenerator-java
///////////////////////////////////////////////////////////////////////////////////////
Main.java // Main Class File
import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; import java.io.*;
public class Main extends JFrame implements ActionListener {
// Creates an icon, attached to a label to act as a banner for the program // Get resource is required for finding the image within the JAR achive once packed final public ImageIcon icon = (new ImageIcon(getClass().getResource("images/ProgramBanner.png"))); JLabel iconHolder = new JLabel(icon);
//Labels and TextFields for the GUI JLabel filmTimeLabel = new JLabel("Time "); JLabel ticketTypeTitle = new JLabel("Ticket "); JLabel ticketTypeCostTitle = new JLabel("Total Price: "); JLabel ticketQuantityTitle = new JLabel("Ticket Quantity: "); JLabel adultLabel = new JLabel("Adult"); JLabel childLabel = new JLabel("Child"); JLabel oapLabel = new JLabel("OAP"); JTextField ticketQuantityValue = new JTextField(1); JTextField ticketTypeCostValue = new JTextField(4);
// GUI Buttons JButton orderButton = new JButton("ORDER"); JButton resetButton = new JButton("Delete DB");
//Labels For Each Ticket (Do not appear until called by selecting a Ticket Type quantity) JLabel seatLabel1 = new JLabel ("Ticket 1"); JLabel seatLabel2 = new JLabel ("Ticket 2"); JLabel seatLabel3 = new JLabel ("Ticket 3"); JLabel seatLabel4 = new JLabel ("Ticket 4"); JLabel seatLabel5 = new JLabel ("Ticket 5");
// Labels and ComboBoxes for for various Quantity of Tickets (Like their label, also do not appear untill called) JComboBox seatCombo1 = new JComboBox(); JComboBox seatCombo2= new JComboBox(); JComboBox seatCombo3= new JComboBox(); JComboBox seatCombo4= new JComboBox(); JComboBox seatCombo5= new JComboBox();
// Arrays for Quantity of each ticket type Integer[] adultQuantityList = {0,1,2,3,4,5}; Integer[] childQuantityList = {0,1,2,3,4,5}; Integer[] oapQuantityList = {0,1,2,3,4,5};
// Comboboxes to hold the state of the desired quantity of each ticket type JComboBox adultQuantityCombo = new JComboBox(adultQuantityList); JComboBox childQuantityCombo = new JComboBox(childQuantityList); JComboBox oapQuantityCombo = new JComboBox(oapQuantityList);
//ArrayList for a Combobox that shows Film Times String[] timeList = {"-", "1.00 PM", "3.00 PM", "5.00 PM", "7.00 PM", "9.00 PM"}; JComboBox timeCombo = new JComboBox(timeList);
// ArrayList that holds the vaules of seats that are available ArrayList<Integer> seatArrayList = new ArrayList<Integer>(); String timeString = new String();
//Creation of JPanels to be added to the frame JPanel bannerPanel = new JPanel(); JPanel p1 = new JPanel(); JPanel p2 = new JPanel(); JPanel p3 = new JPanel();
public Main() // Constructor Method for GUI { setLocationRelativeTo(null); // Centers the Frame (NOTE: Multi-monitor setups may not center correctly depending on collective resolution setTitle("JSRP Cinema Booking System ver 1.2"); // Set Title of Main Window setSize(775,480); // Set frame resolution to [x,y] pixels setResizable(false); // Keeps Frame a constant resolution (Stops Resizing of Frame by user) setDefaultCloseOperation(EXIT_ON_CLOSE); // Set frame to exit when 'CLOSE' window button is clicked
// Add Panels to the Frame and state Layout Manager constructor arguments add(bannerPanel, BorderLayout.NORTH ); add(p1, BorderLayout.EAST); add(p2, BorderLayout.WEST); add(p3, BorderLayout.SOUTH);
// Addition of Content to respective Panel (Order determines position within panel) bannerPanel.add(iconHolder); bannerPanel.add(ticketQuantityTitle); bannerPanel.add(ticketQuantityValue); bannerPanel.add(ticketTypeCostTitle); bannerPanel.add(ticketTypeCostValue); p1.add(resetButton); p2.add(filmTimeLabel); p2.add(timeCombo); p2.add(adultLabel); p2.add(adultQuantityCombo); p2.add(childLabel); p2.add(childQuantityCombo); p2.add(oapLabel); p2.add(oapQuantityCombo);
// Set number of visible entries when a combobox is selected adultQuantityCombo.setMaximumRowCount(4); childQuantityCombo.setMaximumRowCount(4); oapQuantityCombo.setMaximumRowCount(4); timeCombo.setMaximumRowCount(4);
// Makes textfields non-editable, so that they can be used to display content ticketQuantityValue.setEditable(false); ticketTypeCostValue.setEditable(false);
// Addition of Action Listeners to Objects timeCombo.addActionListener(this); adultQuantityCombo.addActionListener(this); childQuantityCombo.addActionListener(this); oapQuantityCombo.addActionListener(this); orderButton.addActionListener(this); resetButton.addActionListener(this); seatCombo1.addActionListener(this); seatCombo2.addActionListener(this); seatCombo3.addActionListener(this); seatCombo4.addActionListener(this); seatCombo5.addActionListener(this);
setVisible(true); // Set frame to be Visible, thus updating frame with all the selected elements }
//STARTOF ACTIONEVENTS
public void actionPerformed (ActionEvent action) // Method that contain all conditions where an ActionEvent is needed {
// ActionListener for Combobox that displays Film Viewing Times if (action.getSource() == timeCombo) { // Create New Instance of the Database class FullDataBaseGenerator db = new FullDataBaseGenerator();
// Get Name of database String selectedTime = db.returnFileName(timeCombo.getSelectedItem().toString()); System.out.println(selectedTime);
// Make Name of Database global timeString = selectedTime;
// Call DataBase Generator (will generate fresh database for that time if one does not exist) db.FullDataBaseGeneration(selectedTime);
//Fetch array of available seats and pass it to the global ArrayList 'seatArrayList' ArrayList<Integer> timeArray = db.AvailableSeatsArrayReturn(selectedTime); seatArrayList= timeArray;
//Reset any user selection of tickets when a new database is selected adultQuantityCombo.setSelectedIndex(0); childQuantityCombo.setSelectedIndex(0); oapQuantityCombo.setSelectedIndex(0);
//Repaint the Frame repaint(); }
// ActionListener for all ticket type comboboxes collectively if (action.getSource() == adultQuantityCombo || action.getSource() == childQuantityCombo|| action.getSource() == oapQuantityCombo) {
// Remove all existing items from each cb seatCombo1.removeAllItems(); seatCombo2.removeAllItems(); seatCombo3.removeAllItems(); seatCombo4.removeAllItems(); seatCombo5.removeAllItems();
// If the arraylist no longer contains a zero (default answer) // Add a zero at the beginning of the array if (seatArrayList.contains(0) != true) { seatArrayList.add(0, 0); }
// Add contents of the ArrayList to each combobox that display available seats for (int z =0; z< seatArrayList.size(); z++) { seatCombo1.addItem(seatArrayList.get(z)); seatCombo2.addItem(seatArrayList.get(z)); seatCombo3.addItem(seatArrayList.get(z)); seatCombo4.addItem(seatArrayList.get(z)); seatCombo5.addItem(seatArrayList.get(z)); }
// Get new total price as a String and affix to a Label for display on Frame String totalString = getTotal(); ticketTypeCostValue.setText("£" + totalString);
// Calculate total quantity of Tickets and affix to a label for display on Frame Integer adultCounter = Integer.parseInt((adultQuantityCombo.getSelectedItem().toString())); Integer childCounter = Integer.parseInt((childQuantityCombo.getSelectedItem().toString())); Integer oapCounter = Integer.parseInt((oapQuantityCombo.getSelectedItem().toString())); Integer countTotal = (adultCounter + childCounter + oapCounter); ticketQuantityValue.setText(countTotal.toString());
repaint();
// Only 5 tickets can be ordered at one time. Returns error message if more are selected if (countTotal >5) { adultQuantityCombo.setSelectedIndex(0); childQuantityCombo.setSelectedIndex(0); oapQuantityCombo.setSelectedIndex(0); tooManyTickets(); return; }
// Following 6 if statements state what labels/comboboxes should show when the ticket number changes: // E.G. if no tickets are selected then no labels/cbs show // if 3 tickets are chosen, then the labels/cbs for Ticket 1,2 and 3 are shown // if 1 ticket is then chosen, cb/label for Ticket 2 and 3 dissapear by 1 stays if (countTotal ==1 || countTotal ==2 || countTotal ==3 || countTotal ==4|| countTotal ==5 ) { p3.remove(seatLabel2); p3.remove(seatCombo2); p3.remove(seatLabel3); p3.remove(seatCombo3); p3.remove(seatLabel4); p3.remove(seatCombo4); p3.remove(seatLabel5); p3.remove(seatCombo5); p3.add(seatLabel1); p3.add(seatCombo1); }
if (countTotal ==2 || countTotal ==3 || countTotal ==4|| countTotal ==5 ) { p3.remove(seatLabel3); p3.remove(seatCombo3); p3.remove(seatLabel4); p3.remove(seatCombo4); p3.remove(seatLabel5); p3.remove(seatCombo5); p3.add(seatLabel2); p3.add(seatCombo2); }
if (countTotal ==3 || countTotal ==4|| countTotal ==5 ) { p3.remove(seatLabel4); p3.remove(seatCombo4); p3.remove(seatLabel5); p3.remove(seatCombo5); p3.add(seatLabel3); p3.add(seatCombo3); }
if (countTotal ==4|| countTotal ==5 ) { p3.remove(seatLabel5); p3.remove(seatCombo5); p3.add(seatLabel4); p3.add(seatCombo4); }
if (countTotal ==5 ) { p3.add(seatLabel5); p3.add(seatCombo5);
}
if (countTotal ==0 ) { p3.remove(seatLabel1); p3.remove(seatCombo1); p3.remove(seatLabel2); p3.remove(seatCombo2); p3.remove(seatLabel3); p3.remove(seatCombo3); p3.remove(seatLabel4); p3.remove(seatCombo4); p3.remove(seatLabel5); p3.remove(seatCombo5); p3.remove(orderButton); }
// if more tickets than available seats remaining is selected // Then an error message states this face if (countTotal > seatArrayList.size()-1) { notEnoughSeats(); return; }
// if no tickets are selected, then the 'order' button does not appear if (countTotal >0) { p3.add(orderButton); }
repaint(); setVisible(true); }
// ActionListener for orderButton if (action.getSource() == orderButton) {
// Validation for purchase of ticket(s) Integer orderConfirm = JOptionPane.showConfirmDialog(getContentPane(), "Are You sure you want you want to confirm this purchase?", "Confirm Ticket Purchase?", JOptionPane.YES_NO_OPTION); if (orderConfirm ==1) { return; }
// Get the Values of Each Ticket Quantity ComboBox (e.g. 102, 301, etc).. Integer seat1Store = Integer.parseInt(seatCombo1.getSelectedItem().toString()); Integer seat2Store = Integer.parseInt(seatCombo2.getSelectedItem().toString()); Integer seat3Store = Integer.parseInt(seatCombo3.getSelectedItem().toString()); Integer seat4Store = Integer.parseInt(seatCombo4.getSelectedItem().toString()); Integer seat5Store = Integer.parseInt(seatCombo5.getSelectedItem().toString());
//Create an array to hold theese values Integer[] proceedArray = new Integer[5]; proceedArray[0] =seat1Store; proceedArray[1] =seat2Store; proceedArray[2] =seat3Store; proceedArray[3] =seat4Store; proceedArray[4] =seat5Store;
// Repeat code to get value for number of Tickets Integer adultCounter = Integer.parseInt((adultQuantityCombo.getSelectedItem().toString())); Integer childCounter = Integer.parseInt((childQuantityCombo.getSelectedItem().toString())); Integer oapCounter = Integer.parseInt((oapQuantityCombo.getSelectedItem().toString())); Integer countTotal = (adultCounter + childCounter + oapCounter);
// for the number of tickets selected // if that ticket number equals zero (the default value) // then state that not all tickets have been assined seats //128 for (int z=0; z<countTotal; z++) { if (proceedArray[z] ==0) { notSelectedAllSeats(); return; } }
// Create a boolean that when true carries out the database portion of this ActionEvent boolean proceed = false;
// Iterates through each object of the array and compares then with each other for(int i = 0; i<proceedArray.length;i++) { for(int p=0; p<proceedArray.length; p++) { if(i != p) { // if the two compared objects have the same seat number... if(proceedArray[i].equals(proceedArray[p])) { //...and is not a zero (this is a default value, not a seat number) // then call an error stating duplicate seats have been allocated
if (proceedArray[i] != 0 || proceedArray[p] != 0) { duplicateSeats(); return; } } } }
// if no duplications are found, the rest of the event can proceed proceed = true; }
if (proceed == true) {
// Remove the send values from the array seatArrayList.remove(seat1Store); seatArrayList.remove(seat2Store); seatArrayList.remove(seat3Store); seatArrayList.remove(seat4Store); seatArrayList.remove(seat5Store);
try{ // Start try/catch
// State dependables for reading the database FileInputStream fs = new FileInputStream(timeString); DataInputStream in = new DataInputStream(fs); BufferedReader br = new BufferedReader(new InputStreamReader(in));
// While there are Lines left to be read String stringLine; while ((stringLine = br.readLine()) != null) { // Create dependencies for writing to same file BufferedWriter fw = new BufferedWriter(new FileWriter(timeString));
int x=0; // Iterate through the new edited array (orginal array minus selected seat) while(x<seatArrayList.size()) { // Rewrite every line of the text file with each entry in the new array String line = seatArrayList.get(x).toString(); fw.write(line + ";"); x++; } //Close the file writing dependency fw.close();
}
//try/catch end, if error- prints message to command line followed by error code }catch (Exception ex){ System.err.println("Error in database manipulation, code: " + ex.getMessage());}
// Call Pop-up asking user if they want to restart the program for another transaction ticketBought(); } }
// ActionListener for database reset button if(action.getSource() == resetButton) { // When button is selected, A YES/NO messagebox displays Integer end = JOptionPane.showConfirmDialog(getContentPane(), "(NOTE: You can only delete databases upon initially loading"+ " the program and before selecting any databases).\n"+ "If you haven't already done so, please re-run the program and"+ " select this option again if you wish to delete the databases.\n"+ "The Command will still run regardless, but will not work without"+ " the the above steps\n\n"+ "Would you like to Reset all the Databases?\n", "Delete Databases?", JOptionPane.YES_NO_OPTION);
// Is selected answer is YES if (end == 0) { // Ask for validation of deltion Integer yesno1 = JOptionPane.showConfirmDialog(getContentPane(), "Are You sure you want you want to delete all the databases?", "Delete Database?", JOptionPane.YES_NO_OPTION);
// if selected yes if (yesno1 == 0) { // Delete the current instance of the program Main.this.dispose();
//Delete Current database File fileToDelete = new File(timeString); fileToDelete.delete();
// Delete all the databases (stated by name) File file1 = new File("SEAT DATABASE 1.00 PM.txt"); File file2 = new File("SEAT DATABASE 3.00 PM.txt"); File file3 = new File("SEAT DATABASE 5.00 PM.txt"); File file4 = new File("SEAT DATABASE 7.00 PM.txt"); File file5 = new File("SEAT DATABASE 9.00 PM.txt"); file1.delete(); file2.delete(); file3.delete(); file4.delete(); file5.delete();
// Create new instance of the program (hence restart it) new Main(); } } }
}
//END OF ACTIONEVENTS
// Method that returns total price as as String public String getTotal() { // Get current value of each selected option that effects the price Integer childInput = Integer.parseInt(childQuantityCombo.getSelectedItem().toString()); Integer oapInput = Integer.parseInt(oapQuantityCombo.getSelectedItem().toString()); Integer adultInput = Integer.parseInt(adultQuantityCombo.getSelectedItem().toString());
// Pass this value to 'Ticket.getSeatPrice' method to obtain price int childTicketPrice = Ticket.getSeatPrice(childInput, "child"); int adultTicketPrice = Ticket.getSeatPrice(adultInput, "adult"); int oapTicketPrice = Ticket.getSeatPrice(oapInput, "oap");
// Calculate total int total = (childTicketPrice +adultTicketPrice+oapTicketPrice);
//Convert this integer value to a string in the correct format String totalString = Ticket.calculateStringTotal(total);
return totalString; }
public void ticketBought() { // Display Message Stating the price of the ordered tickets JOptionPane.showMessageDialog(getContentPane(), "The total Cost is..£"+getTotal(), "Total Cost", JOptionPane.PLAIN_MESSAGE);
// Ask user if they want to restart the program Integer a = JOptionPane.showConfirmDialog(getContentPane(), "Transaction complete\n Would you like to make another?", "Transaction Complete", JOptionPane.YES_NO_OPTION);
// If yes, deletes current instance of program then creates a new one if (a == 0) {System.out.println("Program Restart Initiated"); Main.this.dispose(); new Main(); } // If no, then instance of program is deleted but no new instance is created, hence ending the program if (a==1) { System.exit(0); } }
// Methods for displaying error messages
public void tooManyTickets() { JOptionPane.showMessageDialog(getContentPane(), "You cannot Process more than 5 tickets at a time!", "Ticket Quantity Error", JOptionPane.ERROR_MESSAGE); }
public void notEnoughSeats() { JOptionPane.showMessageDialog(getContentPane(), "There are not enough seats remaining to process the number of tickets selected", "Ticket Quantity Error", JOptionPane.ERROR_MESSAGE); }
public void duplicateSeats() {
JOptionPane.showMessageDialog(getContentPane(), "There is a duplication of seats!", "Seat Selection Error", JOptionPane.ERROR_MESSAGE); }
public void notSelectedAllSeats() { JOptionPane.showMessageDialog(getContentPane(), "Not all seats have been Assigned!", "Seat Selection Error", JOptionPane.ERROR_MESSAGE); }
// Drawn Graphics Method public void paint(Graphics g) { //ArrayList<Integer> list = new ArrayList<Integer>(array);
super.paint(g); // Clears the frame when method is called
int width = 32; // State width of each Rectangle int height = 32; // State height of each Rectangle
int leftBlockSeatsCol = 6; // State number of Rows in the Left Block int leftBlockSeatsRow = 6; // State number of Columns in the Left Block int centerBlockSeatsRow = 5; // State number of Rows in the Center Block int centerBlockSeatsCol = 8; // State number of Columns in the Center Block int rightBlockSeatsRow = 6; // State number of Rows in the Right Block int rightBlockSeatsCol = 6; // State number of Columns in the Right Block
int leftBlockPosX = 15; // Sets Left Block X-axis Position (in Pixels) int leftBlockPosY = 225; // Sets Left Block Y-axis Position (in Pixels) int centerBlockPosX = (leftBlockPosX+(leftBlockSeatsCol*width)) +50; // Sets Center Block X-axis Position (in Pixels) int centerBlockPosY = 225; // Sets Center Block Y-axis Position (in Pixels) int rightBlockPosX = (centerBlockPosX +(centerBlockSeatsCol*width)) +50; // Sets Right Block X-axis Position (in Pixels) int rightBlockPosY = 225; // Sets Right Block Y-axis Position (in Pixels)
g.setColor(Color.black); // Set Default Draw Color to black
g.drawString("Left Block", (leftBlockPosX+(32*(leftBlockSeatsCol/2)-25)), (leftBlockPosY - 10)); // Title for Each Block g.drawString("Center Block", (centerBlockPosX+(32*(centerBlockSeatsCol/2)-30)), (centerBlockPosY - 10)); g.drawString("Right Block", (rightBlockPosX+(32*(rightBlockSeatsCol/2)-25)), (rightBlockPosY - 10));
Color custom_grey = new Color(175,175,175);
//DRAW LEFT BLOCK OF SEATS
for(int i=0; i<leftBlockSeatsCol;i++) // Loop while there are Columns.. { String colString = new Integer (i+101).toString(); // Creates an Integer of relative Seat Number and converts it to a String g.drawString(colString, leftBlockPosX+5+(i*width), leftBlockPosY+20); // String is affixed to drawSring method and co-ordinates tweaked to center the text in each box. g.drawRect(leftBlockPosX+(i*width), leftBlockPosY, width, height); // Draw a rectangle at the stated X and Y- Pos. The next rect = X-Pos + (width of rectangle * horizontal psotion) [hence in a sequence]
if (seatArrayList.contains((i+101)) != true) // If The Array of available seats does not contain i+101 (Seat 1 of leftBlock is 101, Seat 2 is 102, etc)... {
g.setColor(Color.red); // Then change Draw Color to red g.fillRect(leftBlockPosX+(i*width), leftBlockPosY, width, height); // Fill in the currently iterated rectangle g.setColor(Color.black); // Change color back to default g.drawRect(leftBlockPosX+(i*width), leftBlockPosY, width, height); // Redraw the Rectangle g.drawString(colString, leftBlockPosX+5+(i*width),leftBlockPosY+20); // Redraw the number
}
for(int x=0; x<leftBlockSeatsRow; x++) // For each column, loop while there are Rows.. { String rowString = new Integer((i+(leftBlockSeatsCol*x))+101).toString(); // [As above] g.drawString (rowString, leftBlockPosX+5+(i*width), leftBlockPosY+(x*height)+20);
g.drawRect(leftBlockPosX+(i*width),leftBlockPosY+(x*height), width, height); // Draw A rectangle exactly like before but with Y-Pos + (height * vertical postition) if (seatArrayList.contains((i+(leftBlockSeatsCol*x))+101) != true) // If the Array of available seats does not contain the relevent seat number... { g.setColor(Color.red); // Change Draw Color ot red g.fillRect(leftBlockPosX+(i*width), leftBlockPosY+(x*height), width, height); // Fill in the currently iterated rectangle g.setColor(Color.black); // Change draw color back to default g.drawRect(leftBlockPosX+(i*width), leftBlockPosY+(x*height), width, height); // Redraw outline of rectangle g.setColor(custom_grey); // Set Color to Custom g.drawString (rowString, leftBlockPosX+5+(i*width), leftBlockPosY+(x*height)+20); // Redraw number g.setColor(Color.black); // Change color back to default
} } }
// DRAW CENTER BLOCK OF SEATS
for(int i=0; i<centerBlockSeatsCol;i++) // [Refer to Left Block Code comments] { String colString = new Integer (i+201).toString(); g.drawString (colString, centerBlockPosX+5+(i*width), centerBlockPosY+20); g.drawRect(centerBlockPosX+(i*width), centerBlockPosY, width, height);
if (seatArrayList.contains((i+201)) != true) { g.setColor(Color.red); g.fillRect(centerBlockPosX+(i*width), centerBlockPosY, width, height); g.setColor(Color.black); g.drawRect(centerBlockPosX+(i*width), centerBlockPosY, width, height); g.drawString(colString, centerBlockPosX+5+(i*width), centerBlockPosY+20); }
for (int x=0; x<centerBlockSeatsRow; x++) { String rowString = new Integer ((i+(centerBlockSeatsCol*x))+201).toString(); g.drawString(rowString, centerBlockPosX+5+(i*width), centerBlockPosY+(x*height)+20);
g.drawRect(centerBlockPosX+(i*width), centerBlockPosY+(x*height), width, height); if (seatArrayList.contains((i+(centerBlockSeatsCol*x))+201) != true) { g.setColor(Color.red); g.fillRect(centerBlockPosX+(i*width), centerBlockPosY+(x*height), width, height); g.setColor(Color.black); g.drawRect(centerBlockPosX+(i*width), centerBlockPosY+(x*height), width, height); g.setColor(custom_grey); g.drawString (rowString, centerBlockPosX+5+(i*width), centerBlockPosY+(x*height)+20); g.setColor(Color.black); } } }
//DRAW RIGHT BLOCK OF SEATS
for (int i=0; i<rightBlockSeatsCol;i++) // [Refer to Left Block Code comments] { String colString = new Integer (i+301).toString(); g.drawString(colString, rightBlockPosX+5+(i*width), rightBlockPosY+20);
g.drawRect(rightBlockPosX+(i*width), rightBlockPosY, width, height); if (seatArrayList.contains((i+301)) != true) { g.setColor(Color.red); g.fillRect(rightBlockPosX+(i*width),rightBlockPosY,width,height); g.setColor(Color.black); g.drawRect(rightBlockPosX+(i*width), rightBlockPosY, width, height); g.drawString (colString, rightBlockPosX+5+(i*width), rightBlockPosY+20); }
for(int x=0; x<rightBlockSeatsRow; x++) { String rowString = new Integer ((i+(rightBlockSeatsCol*x))+301).toString(); g.drawString (rowString, rightBlockPosX+5+(i*width), rightBlockPosY+(x*height)+20);
g.drawRect(rightBlockPosX+(i*width), rightBlockPosY+(x*height), width, height); if (seatArrayList.contains((i+(rightBlockSeatsCol*x))+301) != true) { g.setColor(Color.red); g.fillRect(rightBlockPosX+(i*width), rightBlockPosY+(x*height), width, height); g.setColor(Color.black); g.drawRect(rightBlockPosX+(i*width), rightBlockPosY+(x*height), width, height); g.setColor(custom_grey); g.drawString (rowString, rightBlockPosX+5+(i*width), rightBlockPosY+(x*height)+20); g.setColor(Color.black); } } } }
public static void main (String[] args) // Main Method Declaration { new Main(); // Create a new Instance of the main Program when ran } } |
จากคุณ
:
noksaak / kitsumato@yahoo.co.th [2017-11-18 15:40:29]
|
|
ความคิดเห็น #29449 (จาก IP: 182.232.83.68)
ระบบจองตั๋วหนังภาษาจาวา (Java Cinema Booking System)
https://gist.github.com/parsons-Jsr/4043298#file-fulldatabasegenerator-java |
จากคุณ
:
นกแสก / kitsumato@yahoo.co.th [2017-11-18 15:42:48]
|
|
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
|
|