Você está na página 1de 91

1.

DDU PROFILE

Dharmsinh Desai University was established in the year 1968. It was originally an affiliated college namely Dharmsinh Desai Institute of Technology (DDIT). It was granted autonomy first in Gujarat in 1991 & then in the year of 2000 it earned a status of Deemed University by Govt. of India, in recognition of its commendable standards in Academia. In April 2005, the Government of Gujarat declared this Institution as a State University. The University offers manifold undergraduate & postgraduate courses in Engineering & Management; besides providing a scope for doctoral studies. The university also conducts the bachelor level degree courses in Dental Science, Pharmacy & Commerce. The University also conducts the continuing education programmes not simply for the professionals but also for the under-privileged sections of society. The university also offers BE integrated MBA program and Master of Computer Application (MCA).

Faculty

Faculty of Technology Faculty of Business Administration Faculty of Commerce Faculty of Dental Science Faculty of Pharmacy Faculty of Management and Information Science

DDU (Faculty of MIS, Dep. of MCA)

2. PROJECT PROFILE
2.1 PROJECT NAME: MY MOVIE 2.2 PROJECT DESCRIPTION:
The application My Movie is basically a mobile application that lets the users to book their movie show for the multiplexes well in advance. This application is build using JAVA2 platform, Micro Edition. This application is compatible for the mobile phones that are java enable. This application provides the user an easy and very useful way to book their movie show tickets at their preferable multiplex in advance from anywhere. For this, the user is required just to have the application installed on his cell phone device and the GPRS data packet connection. This application provides the user mobility for booking their tickets in advance. As the user starts with this application, the application will first ask the user the city in which he wants to watch the movie. For this a drop down list with the name of cities is been provide to user. The user has to select the city he wants. Once the city is selected the next page will show the name of the movies that are currently shown in the multiplexes. The user has to select the movie that he is interested to see. After selecting the movie the user will get the list of the multiplexes in which that movie is been currently shown with the timing of the shows for that movie. Here there is time constraint, that the user can select the movie show time before 3hrs only. And if this time constraint is not satisfied the application will not allow user to book the tickets for the movie show. Now after selecting the multiplex and the preferable timing, the user has to specify the number of seats he wants and the category of seats for example Gold and Silver. On obtaining this information from user the application will check the availability of seats. After completion of this step if seats are available the application will provide a graphical layout of the sitting arrangement in the theater along with the availability of seats for particular category to user. Now in case if the user is not satisfied with the available seats he can go back to the page that contains the list of multiplexes and show timings and select some other option that suits his requirements or can exit the application. And in case if the seats are not available the user can again go back to the page that shows the list of multiplexes and show timing or can exit the application. The graphical layout of the seats that will be shown to the user on the availability of seats will give a complete idea of the sitting arrangement of the cinema hall. For easy understanding of the users the category of seats will be differentiated by using different sections and even the vacant and booked seats will be differentiated with the use of different colors. DDU (Faculty of MIS, Dep. of MCA) 2

Like for vacant and booked seats the colors will be as follows For vacant----White.

For booked---Red.

Now once the user selects seats from the available seats according to his choice, the application before booking the tickets, will ask his confirmation by showing a complete details of all the selection that he has made till last step so that if any kind of changes is to be made by user can be done before the final booking of seats. On the confirmation of the seats done by the user, the seats will be booked. With this a unique Customer ID will be generated for the user. This ID will be provided to the user. The user should remember this ID for future reference. This ID will help to avoid redundancy and to maintain the list of customers for the particular multiplexes and the movie shows. Now with the completion of all this formalities, the role of application is finished. After this the user has to go to the respective multiplex that he has selected and should go to the booking office with the unique Customer ID that was provided to him by the application. The user has to make the payment for the booked tickets before 3 hrs from the movie show that he has selected else the tickets will be automatically cancelled. This application provides the other two facilities also, View of the booking history. Cancellation of booked tickets.

To use this two facilities the user has to go to the main menu page of the application and select the respective option. On selecting one of these two options, the application will ask user his Customer ID. And according to the Customer ID the application will provide the relevant details requested by the user. On selection of cancellation option the application will provide a complete details of all selection made by the user. There will 2 buttons 1. Cancel 2. Exit. On selecting the cancel button the booked tickets will be cancelled. While on selection of exit button, the user can exit from the application.

DDU (Faculty of MIS, Dep. of MCA)

2.3 DEVELOPMENT TEAM:


This Project has been developed by: 1. Joshi Pratik K. Roll No: 19 ID No: 087015 2. Mishra Riddhi S. Roll No: 30 ID No: 087026

2.4 INTERNAL GUIDE NAME:

Mr. Ajay N Roy Asst. Professor MCA Dept.

DDU (Faculty of MIS, Dep. of MCA)

2.5 PLATFORMS:
Windows XP professional Edition Windows Vista Enterprise Edition

2.6 TECHNOLOGIES USED:


J2EE J2ME

2.7 APPLICATION SERVER:


Apache Tomcat 6.0

2.8 METHODOLOGY USED:


OOSD

2.9 TOOLS USED:


NetBeans 6.0.16 WTK 2.5

2.10 CONSTRAINTS:
As this application has not been deployed on server space, it can only run on stimulator provided by J2ME. So it cannot be shown on actual mobile. But with making some changes and keeping this application on server space this application can definitely give the desired output.

DDU (Faculty of MIS, Dep. of MCA)

3. PROJECT PLANNING

3.1 PROJECT DEFINITION:


The application My Movie is basically a mobile application that lets the users to book their movie show for the multiplexes well in advance.

3.2 PRILIMINARY INVESTIGATION:


3.2.1 PROJECT FESIBILITY:

Does this application contribute to the overall objectives of the Multiplex? This application would contribute to the overall objectives of the Multiplex as under: Book the tickets in advance Enhance Sales Enable Rules based Processing Easy at use for customer Provides mobility to customers Helps to make choice easily Faster service

DDU (Faculty of MIS, Dep. of MCA)

Technical Feasibility

The technical Feasibility test involves questions like Is the users mobile java enable? Is this application is properly installed in users mobile? Is the user having GPRS facility in his mobile? Operational Feasibility

The users of this application should be able to use this application easily, to gain the advantage of easily booking their movie show in advance. This demands good user interface. This application has been developed considering user convenience in mind to make this application user-friendly.

Economic Feasibility

The questions put forward in economic feasibility are: Are there sufficient cost benefits in creating the system? Are the costs of implementation of current system so great that the task of project development is required?

DDU (Faculty of MIS, Dep. of MCA)

3.2.2 SELECTING THE PROJECT DEVELOPMENT STRATEGY:

This application is developed using the OO approach and the Milestones that are identified in order to complete the entire Project in the time duration . Milestones are identified for every module of Integrated Workflow Document Management System. Table: Milestones and Deliverables PHASE DELIVERABLES System Requirement Gathering and Requirement and analysis. Analysis Functional Specifications Non Functional Specifications System Design Database Design Class diagram Sequence Diagram Use Case Diagram Form layouts Implementation and Testing The output obtained for the required functionality after implementing and doing various types of testing

PURPOSE It gives exact understanding of the users requirements. It gives the logical structure that describes the system.

It gives the required module

3.3 DEVELOP WORK PLAN:


DDU (Faculty of MIS, Dep. of MCA) 8

3.3.1 ORIGINAL ACTIVITY CHART:

A u2 g0 1 0

S e2 p0 1 0

O 2010 ct

ID

T ask N a m e

S ta r t

F in is h

D u r a t io n
7/2 5 8/1 8/8 8/1 5 8/2 2 8/2 9 9/5 9/1 2 9/1 9 9/2 6 1 /03

1 A n a ly s is

7/2 /6 0 1 0 8/1 /3 0 1 0 2 2

2.8 w 3 2w 3w 2w 1w 1w 2

2 S y s t e m D e s ig n in g 8/1 /3 0 1 0 8/2 /6 0 1 0 2 2 3 A p p lic a t io n C o d in g 8/2 /6 0 1 0 9/1 /5 0 1 0 2 2 4 T e s&t Bin ug g R e s o lu t io n9/1 /5 0 1 0 9/2 /8 0 1 0 2 2 5 I m p le m e n t a t io n 6 D o c u m e n t a t io n 9/2 /8 0 1 0 1 /0 0 1 0 2 4/2 7/2 /6 0 1 0 1 /0 /6 0 1 0 2 12

Time Allotted to Various Activities

4. SYSTEM ANALYSIS
DDU (Faculty of MIS, Dep. of MCA) 9

4.1 STEPS TO DETERMINE REQUIREMENT:


Plan/Manage: to prepare for & manage the requirements. Obtain: Collect information from various source. Understand Analyze the obtained information. Validate Confirm mutual understanding of the requirements.

Step 1: planning/Manage Identify the client resource: According to the first step the resources had been identified. The required resources are GPRS enable mobile phone and internet connection. Identify the key success parameters: Within the budget: Accessing of the application is within the customer budget as it doesnt charge anything access charge the nominal charge of net is been deducted. On Schedule: Whenever the customer wants to access the application it is available for use. So there no need to wait for long time, for its availability. The Application is working on schedule as per the current date and time. And frequently updated with new modifications, So customer will always get the latest information. The project is being continuously monitored for the required changes and for latest updation and modification that are required.

Step 2: Obtain Information

DDU (Faculty of MIS, Dep. of MCA)

10

The main methods for information gathering are Questionnaires and Interviewing. We have gone through the process of questionnaires with users of similar application and the facility providers. In questioning with the customer we came to know that fast access and immediate conformations are important and user wants that with low cost spending. We have gone through the process of interview with the authority of the multiplex regarding the facility they want and the rules they want to be followed by the user. In accordance of this requirement we tried to create our application which is useful to user as well as the service provider. We are gone through the Survey as well for more information gathering and by doing so we come to know about the user interest in booking of the tickets. We have included all the desired and required functionality in this application. Step 3: Understand After gathering all the required information we have analyzed it properly to make the application good enough. We have gathered all the information and linked it to the source document to understand it and to make a complete application. By doing this we realized many important facts which we have included into our application like time constrain, ticket collection constraint. The next step we have performed is the root cause analyze in which we understood the basic and the most important facts for booking. The main advantage of this is user can use this application at any time and from any where. And that is what the basic need of this fast moving world. The consistency is also very important so the application should be consistent all the time. We have gone through the consistency check for our application and tested it correctly. The second check is completeness in which the user should be fully satisfied with the application completely. The application would reach and make all the required functioning. And the system also work with correctness check, where user can get all the required information like about movie, city, show time, date ,sheets ,and rates as well. To validate the requirement we gone through the special person and the project guide and to those who constantly in touch with this kind of application. We also gone through with the different techniques like data modeling and process modeling to verify and understand the completeness of the requirement. Step 4: Validation DDU (Faculty of MIS, Dep. of MCA) 11

In this step we validate all the requirements and the needed functions of the application by applying the testing strategy in which we analyze with the current scenario and user specified requirement. And test whether our application meet with the required parameters or not. By successfully applying this methodology we have validated the requirements.

4.2 Analysis Diagram


DDU (Faculty of MIS, Dep. of MCA) 12

4.2.1 USE CASE DIAGRAM:

Administrator Use Case:

General Use Case: DDU (Faculty of MIS, Dep. of MCA) 13

MY MOVIE

Information Gathering

Ticket Booking

User

Cancellation

View Information

Help

DDU (Faculty of MIS, Dep. of MCA)

14

Booking Use Case:

MY MOVIE

Provide Information

Process Information

Seat Layout

User

Conformation

Ticket Booked And Generate Unique Id

Cancellation Use Case: DDU (Faculty of MIS, Dep. of MCA) 15

MY MOVIE

Request Cancellation

Provides Customer ID

Customer ID Verification User

Conformation

Ticket Cancelled

Help Use Case: DDU (Faculty of MIS, Dep. of MCA) 16

M Y M O V IE

R e q u e s t fo r In fo rm a tio n

U se r

P ro v id e s In fo rm a tio n

Information view Use Case: DDU (Faculty of MIS, Dep. of MCA) 17

M MOV Y IE

Request History Info

Provides Custom er ID User

Process Inform ation

View History Info

4.2.2 SEQUENCE DIAGRAM: DDU (Faculty of MIS, Dep. of MCA) 18

Ticket Booking Sequence Diagram:

DDU (Faculty of MIS, Dep. of MCA)

19

Cancellation Sequence Booking:

User Interface Class

Booking Class

Data Objects

user Reqest for cancellation Enter CustID Verification of CustID

Successfull Varification Ticket Cancelled

Ticket successfully Cancelled

DDU (Faculty of MIS, Dep. of MCA)

20

View Information Sequence Diagram:

4.2.3 CLASS DOMAIN DIAGRAM: DDU (Faculty of MIS, Dep. of MCA) 21

5. SYSTEM DESIGN
DDU (Faculty of MIS, Dep. of MCA) 22

5.1Architectural:
5.1.1 SYSTEM FLOW DIAGRAM:

5.1.2 CLASS DIAGRAM:

DDU (Faculty of MIS, Dep. of MCA)

23

D a ta P ro v id e r -A c t io ne le t:es t rin g _d -A c t io ne _c it y s t ri n g _g t : -A c t io ne _m o v ie s t rin g _g t : -A c t io ne _re c ie pst t r in g _g t : -A c t io ne _s e a t c a t e g s trrin g _g t :o y -A c t io ne _s h o ws t r in g _g t : -A c t io ne _t h e a t :esr t rin g _g t -u rl: s t r in g +D e le t e H is t o u yr ls t rin) g:s t r in g (in r : +g e t S e rv e rR e s(in ounrsls et r in) g:s t r in g p : +r e q u e s t C () ie tsri n g it :s 1.. * +r e q u e s t M o v ieos rC : ist y rin) g:s t rin g (in f t +r e q u e s t S h o w n im reC : it yt ri n, gn f o rM o: v ieri n, gn f o rT h e :ast errin) g:s t rin g (i T f o s i st i t +r e q u e s t T h e(int ef osrC : it y rin, g f o r M o: vs iterin) g:s t ri n g a r s t in +S u b m i t F in a(in faot aC : it yt r in, g F o rM o: v it e , g f o rT h e :ast terir n, gn f o rC a t e :gsot ry ) g:s t r in g lD r s in s rin in i rin +v ie w H is(in rye f :I d t rin) g:s t r in g to r s
1 0. .1 1

B o o k S h o w M id le t -d is p O : bDj is p la y o b j e c t -u iP ro v id U rI P ro v i d e r o b je c t :e +g e t D i s p O () je ci ts p la y o b je c t b :D
1

U ti l i t +S e le c t e d :C itrin g sty +S e le c t e d S: h o rin g stw +S e le c e d M :os vt rin g ie +S e le c t e d T h :esat trin g re +N o o f t ic :kset tri n g +S e a t C a t e :gsot ryn g ri +S h o w A(il n rtS h o w T si ttle ) g:s t ri n g e : rin

U IP ro v id e -d a t a P r o v :id eart a P ro v id e r O b je c t D -d is p D is p la y O b je c t : +C o m m a n d A c t C o m m : ao n dj e ,ci n D i s p la y: a b le )c :tv o i d (in io n b t o b je +S h o w C i t y S(inr eSecnre: e n j e )c :tv o id c ob +S h o w M o v (in L Ssct r e: e n je )c t:v o i d ie i ob +S h o w T h e a t(ienr LSisc tr e: eo nb je )c :tv o id +S h o w S h o w T nmSi nc gre: eo n je )c :tv o id (i i b +S h o w S e a t C a (i ne g ocry : e n rin) g:v o i d g S re s t

1..* 1..*

C o m m u n i c a to r -U R :Ls t rin g -E rro rC o: d eri n g st -I d e n t if y R e s (ino n seer v e r R e s :psot n s) e:s t rin g p S rin g -E n c o d e U) R:s L rin g ( t +U R L v i a g p rs :r ls t r in) g:s t r in g (in u

Servlet Classes:
DDU (Faculty of MIS, Dep. of MCA) 24

C ateg o ry -c ity : s tring -m ov ie: s tring -theatre: s tring -s how tim e s tring : -s how lis:t s tring +getD at abas eC onnec () : v oid tion +P roc es s reques t R es pons:eobjec,t in R eques: tobjec)t : v oid (in

C ity -C onnec tionobjec t : -ac tion: objec t -S tring: objec t +getC onnec tion: v oid () +P roc es s R eques t R eques: tobjec,t in R es pons:eobjec)t : v oid (in T h eatre -s tr: objec t -reqc ount int : -ac tion: s tring -c ity: s tring -m ov ie: s tring -out : objec t +getC onnc etion: v oid () +P roc es s R eques t R eques:tobjec ,t in R es pons:eobjec )t : v oid (in D eleteS ervl et -s tr : s tring -refid : s tring -id : int -s ql : s tring +getC onnc etion: v oid () +proc es s R eques t R eques:tobjec,t in R es pons:eobjec )t : v oid (in

H i sto ryS ervlet -refid: s tring -rs : objec t -s tr: objec t -out : objec t +getC onnc tion : v oid () +P roc es s R eques t R eques:tobjec ,t in R es pons:eobjec )t : v oid (in

S h o w T im e -s t r: s tring -m ov ie: s tring -ac tion: s t ring -theat re: s tring -rs : objec t -out : objec t -reqc ount int : +getC onnc etion: v oid () +proc es s R eques t reques:t objec,t in res pons :eobjec)t : v oid (in

M o vie -reqc ount int : -s tr : s tring -c ity : s tring -rs : objec t +getC onnc etion: v oid () +proc es s R eques t R eques:tobjec,t in R es pons:eobjec )t : v oid (in

5.1.3 ACTIVITY DIAGRAM: DDU (Faculty of MIS, Dep. of MCA) 25

Diagram 1: Ticket Booking

Diagram 2:

DDU (Faculty of MIS, Dep. of MCA)

26

View Information

Diagram 3: DDU (Faculty of MIS, Dep. of MCA)

Diagram 4: 27

Cancellation

Help

5.1.4 DATA BASE RELATIONSHIP DIAGRAM: DDU (Faculty of MIS, Dep. of MCA) 28

5.1.5 DATA DICTIONARY:

DDU (Faculty of MIS, Dep. of MCA)

29

Table Name: Booking Primary key: Booking ID Foreign key: -This table stores all the details about tickets booked Sr.No Field Name 1 Booking ID 2 City 3 Movie Name 4 Theatre 5 Show 6 Category 7 No Of Seats Data Type Number Text Text Text Text Text Number Field Size Long Integer 50 50 50 5 50 Long Integer Description Booking Identification City Name Movie Name Theatre name Show Time Seat Category No of Seat Booked by User

Table Name: Category Primary key: Category ID Foreign key: -This table stores all the details about Category of seats. Sr.No Field Name 1 Category ID 2 Name Data Type Text Text Field Size 20 50 Description Seat Category Identification Seat Category Name

Table Name: Movie DDU (Faculty of MIS, Dep. of MCA) 30

Primary key: Movie ID, Screen ID, Show ID Foreign key: -This table stores all the details related to Movie. Sr.No Field Name 1 Movie ID 2 Screen ID 3 Show ID 4 Movie Name 5 Booked Seats Data Type Text Text Text Text Number Field Size 20 20 20 50 Long Integer Description Movie Identification Screen Identification Movie Show Identification Movie name No Of Booked seats for Movie

Table Name: Multiplex Primary key: Multiplex ID Foreign key: -This table stores all the details related to Multiplex. Sr.No Field Name 1 Multiplex ID 2 Name 3 City 4 No of Screens Data Type Text Text Text Text Field Size 20 50 50 50 Description Multiplex Identification Name Of Multiplex City Name of Multiplex location No of Screens in Multiplex

Table Name: Rate Primary key: Category ID, Show ID DDU (Faculty of MIS, Dep. of MCA) 31

Foreign key: -This table stores all the details related to Rate of seats. Sr.No Field Name 1 Category ID 2 Show ID 3 Amt Data Type Text Text Number Length 20 20 Long Integer Description Seat Category Identification Movie Show Identification Rate for seats as per as Category

Table Name: Screen Primary key: Screen ID, Category ID Foreign key: -- Multiplex ID This table stores all the details related to Screen in Multiplex. Sr.No Field Name 1 Screen ID 2 Category ID 3 Multiplex ID 4 Total Seats Data Type Text Text Text Text Length 20 20 20 Long Integer Description Screen Identification Seat Category Identification Multiplex Identification No of seats Booked

Table Name: Show Primary key: Show ID DDU (Faculty of MIS, Dep. of MCA) 32

Foreign key: -This table stores all the details about the available shows in Multiplex. Sr.No Field Name 1 Show ID 2 Time Data Type Text Text Field Size 20 50 Description Movie Show Identification Movie Show Time

5.2 INTERFACE:

DDU (Faculty of MIS, Dep. of MCA)

33

MAIN SCREEN:

CITY SELECTION:

MOVIE LIST:

MULTIPLEX SELECTION: 34

DDU (Faculty of MIS, Dep. of MCA)

SHOW TIMINGS:

CATEGORY SELECTION:

DDU (Faculty of MIS, Dep. of MCA)

35

NO OF SEATS:

SEAT LAYOUT:

DDU (Faculty of MIS, Dep. of MCA)

36

DDU (Faculty of MIS, Dep. of MCA)

37

RECEIPT GENERATED:

VIEW HISTORY:

DDU (Faculty of MIS, Dep. of MCA)

38

REFERENCE ID:

VIEW HISTORY:

DDU (Faculty of MIS, Dep. of MCA)

39

SELECT HELP:

PROVIDE INFORMATION:

DDU (Faculty of MIS, Dep. of MCA)

40

6. IMPLEMENTATION:
DDU (Faculty of MIS, Dep. of MCA) 41

6.1 Coding: BOOKSHOWMIDLET:


package Code; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.midlet.MIDlet; public class BookShowMidlet extends MIDlet implements CommandListener { private static Display dispObj; public UIProvider uiProvider; public BookShowMidlet(){ dispObj = Display.getDisplay(this); } protected void startApp() { uiProvider = new UIProvider(this, dispObj); } protected void pauseApp() { } protected void destroyApp(boolean arg0) { } public void commandAction(Command cmd, Displayable d) { } public void exitApp(){ destroyApp(true); notifyDestroyed(); } public static Display getDispObject(){ return dispObj; } DDU (Faculty of MIS, Dep. of MCA) 42

DATAPROVIDER MIDLET:

public class DataProvider { final String URL = "http://localhost:8084/FinalServlet/"; final public static String ACTION_GET_CITIES = "city"; final public static String ACTION_GET_MOVIES = "movies"; final public static String ACTION_GET_SHOWS = "showtimings"; final public static String ACTION_GET_THEATERS = "theaters"; final public static String ACTION_GET_SEATCATEGORY = "category"; final public static String ACTION_DELETE_HISTORY = "delservlet"; final public static String ACTION_GET_RECEIPT = "refid"; public String[] requestCities() throws Exception { StringBuffer sb = new StringBuffer(URL); //sb.append("action=").append(ACTION_GET_CITIES); sb.append("CityServlet"); return getServerResponse(sb.toString()); } public String[] requestMovies(String forCity) throws Exception { StringBuffer sb = new StringBuffer(URL); //sb.append("action=").append(ACTION_GET_MOVIES); sb.append("MovieServlet"); sb.append("?city=").append(forCity); return getServerResponse(sb.toString()); } public String[] requestShowTimings(String forCity, String forMovie, String forTheatre) throws Exception { StringBuffer sb = new StringBuffer(URL); //sb.append("action=").append(ACTION_GET_SHOWS); sb.append("ShowtimeServlet?"); sb.append("city=").append(forCity); sb.append("&movie=").append(forMovie); sb.append("&theatre=").append(forTheatre); return getServerResponse(sb.toString()); }

DDU (Faculty of MIS, Dep. of MCA)

43

public String[] requestTheatres(String forCity, String forMovie) throws Exception { StringBuffer sb = new StringBuffer(URL); //sb.append("action=").append(ACTION_GET_THEATERS); sb.append("TheatreServlet?"); sb.append("city=").append(forCity); sb.append("&movie=").append(forMovie); return getServerResponse(sb.toString()); } public String[] requestSeatCategory(String forCity, String forMovie, String forTheatre, String forShowTime) throws Exception { StringBuffer sb = new StringBuffer(URL); //sb.append("action=").append(ACTION_GET_SEATCATEGORY); sb.append("CategoryServlet?"); sb.append("&city=").append(forCity); sb.append("&movie=").append(forMovie); sb.append("&showtime=").append(forShowTime); sb.append("&theatre=").append(forTheatre); return getServerResponse(sb.toString()); } public String submitFinalData(String forCity, String forMovie, String forTheatre, String forShowTime, String seatCategory){ try { StringBuffer sb = new StringBuffer(URL); sb.append("SubmitServlet?"); sb.append("city=").append(forCity); sb.append("&movie=").append(forMovie); sb.append("&showtime=").append(forShowTime); sb.append("&theatre=").append(forTheatre); sb.append("&category=").append(seatCategory); return new HttpCommunicator().hitURLViaGPRS(sb.toString()); }catch(Exception e){ return null; } } private String[] getServerResponse(final String url) throws Exception { try { return Utility.Split(new HttpCommunicator().hitURLViaGPRS(url), '#'); }catch(Exception e){ DDU (Faculty of MIS, Dep. of MCA) 44

throw new Exception(e.getMessage()); } } public String deleteHistory(String refId){ try { StringBuffer sb = new StringBuffer(URL); sb.append("DelServlet?"); sb.append("refid=").append(refId); return new HttpCommunicator().hitURLViaGPRS(sb.toString()); }catch(Exception e){ return null; } } public String viewHistory(String refId){ try { StringBuffer sb = new StringBuffer(URL); sb.append("HistoryServlet?"); sb.append("refid=").append(refId); return new HttpCommunicator().hitURLViaGPRS(sb.toString()); }catch(Exception e){ return null; } } }

COMMUNICATOR MIDLET:
package Code; import java.io.*; import javax.microedition.io.*; public class HttpCommunicator implements Runnable { private HttpConnection conn; private InputStream io; private String URL = ""; private String response; private Thread sendThread; private String errorCode = null; // ORIGINAL METHOD public String hitURLViaGPRS(String pURL) throws Exception { URL = pURL; DDU (Faculty of MIS, Dep. of MCA) 45

System.out.println("URL = " + URL); URL = urlEncoder(URL); //System.out.println("ENCODED URL= " + URL); sendThread = new Thread(this); sendThread.setPriority(Thread.MAX_PRIORITY); sendThread.start(); try { //Thread.sleep(5000); sendThread.join(); } catch (InterruptedException ex) { } if (errorCode == null && response != null) { return response; } else { if (errorCode.startsWith("4")) { throw new Exception("Failed sending [" + conn.getResponseCode() + "]"); } else if (errorCode.startsWith("5")) { throw new Exception("Failed sending [" + conn.getResponseCode() + "]"); } else if (errorCode.equals("SecurityEx")) { throw new Exception("Permission denied (SecurityEx)"); } else if (errorCode.equals("IOEx")) { throw new Exception("Failed to reach server, Try again"); } else { throw new Exception("Unmapped Exception"); } } } /*public String hitURLViaGPRS(String pURL) throws Exception { try { Thread.sleep(1000); } catch (InterruptedException ex) { } System.out.println(pURL); response = identifyResponse(pURL); return response; }*/ public void run() { conn = null; io = null; String str; try { //URL = urlEncoder(URL); DDU (Faculty of MIS, Dep. of MCA) 46

//System.out.println("AFTER ENCODING = "+URL); conn = (HttpConnection) Connector.open(URL); conn.setRequestMethod(HttpConnection.GET); if (conn.getResponseCode() == HttpConnection.HTTP_OK) { io = conn.openInputStream(); int length = (int) conn.getLength(); if (length != -1) { byte incomingData[] = new byte[length]; io.read(incomingData); str = new String(incomingData); } else { ByteArrayOutputStream bytestream = new ByteArrayOutputStream(); int ch; while ((ch = io.read()) != -1) { bytestream.write(ch); } str = new String(bytestream.toByteArray()); bytestream.close(); } response = identifyResponse(str); System.out.println("resp =" + response); //response always starts and ends with <"> so have to remove (JSON) //sendStatus = sendStatus.substring(1, sendStatus.length()-1); //System.out.println(sendStatus); } if (conn.getResponseCode() >= 400 && conn.getResponseCode() <= 499) { errorCode = "" + conn.getResponseCode(); } if (conn.getResponseCode() >= 500 && conn.getResponseCode() <= 599) { errorCode = "" + conn.getResponseCode(); } } catch (SecurityException se) { errorCode = "SecurityEx"; } catch (IOException ioex) { errorCode = "IOEx"; } } private String identifyResponse(String serverResponse) { if (serverResponse.startsWith("HistoryDelete")){

DDU (Faculty of MIS, Dep. of MCA)

47

return serverResponse.substring(serverResponse.indexOf("|")+1, serverResponse.length()); } else if (serverResponse.startsWith("history")){ return serverResponse.substring(serverResponse.indexOf("|")+1, serverResponse.length()); } else if (serverResponse.startsWith(DataProvider.ACTION_GET_RECEIPT)){ return serverResponse.substring(serverResponse.indexOf("|")+1, serverResponse.length()); } // action= //int indOfAction = serverResponse.indexOf("action"); //indOfAction += 7; // index of "=" int indOfAction = serverResponse.indexOf("|"); //int endOfAction = serverResponse.indexOf("&", indOfAction); //if (endOfAction == -1) // endOfAction = serverResponse.length(); String actionRequest = serverResponse.substring(0, indOfAction); if (actionRequest.equalsIgnoreCase(DataProvider.ACTION_GET_CITIES)) { String cityListResponse = serverResponse; //DataProvider.ACTION_GET_CITIES +"|Baroda#Ahmedabad#Surat#Bharuch#Rajkot"; String actionInResponse = cityListResponse.substring(0, cityListResponse.indexOf('|')); if (actionInResponse.equalsIgnoreCase(DataProvider.ACTION_GET_CITIES)) { return cityListResponse.substring(cityListResponse.indexOf('|') + 1, cityListResponse.length()); } else { return null; } } else if (actionRequest.equalsIgnoreCase(DataProvider.ACTION_GET_MOVIES)) { String movieListResponse = serverResponse; //DataProvider.ACTION_GET_MOVIES +"|Dabaang#Once upon#Family#A team"; String actionInResponse = movieListResponse.substring(0, movieListResponse.indexOf('|')); if (actionInResponse.equalsIgnoreCase(DataProvider.ACTION_GET_MOVIES)) {

DDU (Faculty of MIS, Dep. of MCA)

48

return movieListResponse.substring(movieListResponse.indexOf('|') + 1, movieListResponse.length()); } else { return null; } } else if (actionRequest.equalsIgnoreCase(DataProvider.ACTION_GET_THEATERS)) { String theatreListResponse = serverResponse; //DataProvider.ACTION_GET_THEATERS +"|Inox#Chandan#PVR#Cinemall"; String actionInResponse = theatreListResponse.substring(0, theatreListResponse.indexOf('|')); if (actionInResponse.equalsIgnoreCase(DataProvider.ACTION_GET_THEATERS)) { return theatreListResponse.substring(theatreListResponse.indexOf('|') + 1, theatreListResponse.length()); } else { return null; } } else if (actionRequest.equalsIgnoreCase(DataProvider.ACTION_GET_SHOWS)) { String showTimingsResponse = serverResponse; //DataProvider.ACTION_GET_SHOWS +"|10:00 AM#12:00 PM# 2:00 PM#6:00 PM"; String actionInResponse = showTimingsResponse.substring(0, showTimingsResponse.indexOf('|')); if (actionInResponse.equalsIgnoreCase(DataProvider.ACTION_GET_SHOWS)) { return showTimingsResponse.substring(showTimingsResponse.indexOf('|') + 1, showTimingsResponse.length()); } else { return null; } } else if (actionRequest.equalsIgnoreCase(DataProvider.ACTION_GET_SEATCATEGORY)) { String seatCategoryResponse = serverResponse; //DataProvider.ACTION_GET_SEATCATEGORY + "|Silver#Gold"; String actionInResponse = seatCategoryResponse.substring(0, seatCategoryResponse.indexOf('|')); if (actionInResponse.equalsIgnoreCase(DataProvider.ACTION_GET_SEATCATEGORY) ){ return seatCategoryResponse.substring(seatCategoryResponse.indexOf('|') + 1, seatCategoryResponse.length()); } else { return null; } DDU (Faculty of MIS, Dep. of MCA) 49

} else { return null; } } public static String urlEncoder(String s) { if (s == null) { return s; } StringBuffer sb = new StringBuffer(s.length() * 3); try { char c; for (int i = 0; i < s.length(); i++) { c = s.charAt(i); if (c == '&') { sb.append("&"); } else if (c == ' ') { sb.append("%20"); } else if ((c >= ',' && c <= ';') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_' || c == '?' || c == '=') { sb.append(c); } else { sb.append('%'); if (c > 15) { sb.append(Integer.toHexString((int) c)); } else { sb.append("0" + Integer.toHexString((int) c)); } } } } catch (Exception ex) { return (null); } return (sb.toString().trim()); } }

DDU (Faculty of MIS, Dep. of MCA)

50

USERINTERFACE MIDLET:
package Code; import javax.microedition.lcdui.*; public class UIProvider { Display disp; BookShowMidlet midlet; List lstCityList; List lstMoviesList; List lstShowTimings; List lstTheatres; List lstSeatCategory; Form frmSeats; DataProvider dataProvider = new DataProvider(); List lstWelcome; public UIProvider(BookShowMidlet midlet, Display disp) { this.midlet = midlet; this.disp = disp; this.disp.setCurrent(getWelcomeScreen()); //this.disp.setCurrent(new SeatMap()); } public Screen getWelcomeScreen() { if (lstWelcome == null) { lstWelcome = new List("BOOK MY SHOW", List.IMPLICIT); lstWelcome.append("Purchase Ticket", null); lstWelcome.append("View History", null); lstWelcome.append("Help", null); lstWelcome.append("Exit", null); Font labelFont = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE); for (int i = 0; i < lstWelcome.size(); i++) { lstWelcome.setFont(i, labelFont); } lstWelcome.setCommandListener(new CommandListener() { public void commandAction(Command command, Displayable d) { String selected = lstWelcome.getString(lstWelcome.getSelectedIndex()); if (selected.equals("Exit")) { midlet.exitApp(); }else if (selected.equals("Help")){ DDU (Faculty of MIS, Dep. of MCA) 51

showHelp(); } else if (selected.equals("View History")) { showHistoryForm(lstWelcome); } else if (selected.equals("Purchase Ticket")) { disp.setCurrent(WaitCanvas.getInstance()); new Thread(new Runnable() { public void run() { try { showCityListScreen(lstWelcome); } catch (Exception e) { Utility.showAlert("City-Error", "No Data Found.", AlertType.ERROR, lstWelcome); } } }).start(); } } }); } return lstWelcome; } public void showCityListScreen(final Screen parentScreen) throws Exception { lstCityList = new List("CITY LIST", List.IMPLICIT); String[] citylist = dataProvider.requestCities(); Font labelFont = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE); for (int i = 0; i < citylist.length; i++) { lstCityList.append(citylist[i], Utility.img); } for (int i = 0; i < citylist.length; i++) { lstCityList.setFont(i, labelFont); } lstCityList.addCommand(new Command("Back", Command.BACK, 0)); lstCityList.setCommandListener(new CommandListener() { public void commandAction(Command cmd, Displayable d) { DDU (Faculty of MIS, Dep. of MCA) 52

if (cmd == List.SELECT_COMMAND) { disp.setCurrent(WaitCanvas.getInstance()); new Thread(new Runnable() { public void run() { try { Utility.selectedCity = lstCityList.getString(lstCityList.getSelectedIndex()); showMoviesListScreen(lstCityList); } catch (Exception e) { Utility.showAlert("Movie-Error", "No Data Found.", AlertType.ERROR, lstCityList); } } }).start(); } else if (cmd.getCommandType() == Command.BACK) { disp.setCurrent(parentScreen); } } }); disp.setCurrent(lstCityList); } public void showMoviesListScreen(final Screen parentScreen) { lstMoviesList = new List("MOVIES LIST", List.IMPLICIT); String[] movies = null; try { movies = dataProvider.requestMovies(Utility.selectedCity); } catch (Exception e) { Utility.showAlert("Movie-Error", "No Data Found.", AlertType.ERROR, lstCityList); } Font labelFont = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE); for (int i = 0; i < movies.length; i++) { lstMoviesList.append(movies[i], Utility.img); } for (int i = 0; i < movies.length; i++) { lstMoviesList.setFont(i, labelFont); }

DDU (Faculty of MIS, Dep. of MCA)

53

lstMoviesList.addCommand(new Command("Back", Command.BACK, 0)); lstMoviesList.setCommandListener(new CommandListener() { public void commandAction(Command cmd, Displayable d) { if (cmd == List.SELECT_COMMAND) { disp.setCurrent(WaitCanvas.getInstance()); new Thread(new Runnable() { public void run() { try { Utility.selectedMovie = lstMoviesList.getString(lstMoviesList.getSelectedIndex()); showTheatreList(lstMoviesList); } catch (Exception e) { Utility.showAlert("Movie-Error", "No Data Found", AlertType.ERROR, lstCityList); } } }).start(); } else if (cmd.getCommandType() == Command.BACK) { disp.setCurrent(parentScreen); } } }); disp.setCurrent(lstMoviesList); } public void showTheatreList(final Screen parentScreen) { lstTheatres = new List("THEATERS", List.IMPLICIT); String[] theatres = null; try { theatres = dataProvider.requestTheatres(Utility.selectedCity, Utility.selectedMovie); } catch (Exception e) { Utility.showAlert("Theatre-Error", "No Data Found.", AlertType.ERROR, lstMoviesList); } Font labelFont = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE); DDU (Faculty of MIS, Dep. of MCA) 54

for (int i = 0; i < theatres.length; i++) { lstTheatres.append(theatres[i], Utility.img); } for (int i = 0; i < theatres.length; i++) { lstTheatres.setFont(i, labelFont); } lstTheatres.addCommand(new Command("Back", Command.BACK, 0)); lstTheatres.setCommandListener(new CommandListener() { public void commandAction(Command cmd, Displayable d) { if (cmd == List.SELECT_COMMAND) { disp.setCurrent(WaitCanvas.getInstance()); new Thread(new Runnable() { public void run() { try { Utility.selectedTheatre = lstTheatres.getString(lstTheatres.getSelectedIndex()); showShowTimings(lstMoviesList); } catch (Exception e) { Utility.showAlert("Movie-Error", "No Data Found", AlertType.ERROR, lstCityList); } } }).start(); } else if (cmd.getCommandType() == Command.BACK) { disp.setCurrent(parentScreen); } } }); disp.setCurrent(lstTheatres); } public void showShowTimings(final Screen parentScreen) { lstShowTimings = new List("SHOW TIMINGS", List.IMPLICIT); String[] shows = null; try { shows = dataProvider.requestShowTimings(Utility.selectedCity, Utility.selectedMovie, Utility.selectedTheatre); DDU (Faculty of MIS, Dep. of MCA) 55

} catch (Exception e) { Utility.showAlert("ShowTimigs-Error", "No Data Found.", AlertType.ERROR, lstShowTimings); } Font labelFont = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE); for (int i = 0; i < shows.length; i++) { lstShowTimings.append(shows[i], Utility.img); } for (int i = 0; i < shows.length; i++) { lstShowTimings.setFont(i, labelFont); } lstShowTimings.addCommand(new Command("Back", Command.BACK, 0)); lstShowTimings.setCommandListener(new CommandListener() { public void commandAction(Command cmd, Displayable d) { if (cmd == List.SELECT_COMMAND) { disp.setCurrent(WaitCanvas.getInstance()); new Thread(new Runnable() { public void run() { try { Utility.selectedShow = lstShowTimings.getString(lstShowTimings.getSelectedIndex()); showSeatCategoryList(lstShowTimings); } catch (Exception e) { Utility.showAlert("Movie-Error", "No Data Found.", AlertType.ERROR, lstCityList); } } }).start(); } else if (cmd.getCommandType() == Command.BACK) { disp.setCurrent(parentScreen); } } }); disp.setCurrent(lstShowTimings); } public void showSeatCategoryList(final Screen parentScreen) { DDU (Faculty of MIS, Dep. of MCA) 56

lstSeatCategory = new List("Seat Categories", List.IMPLICIT); String[] categories = null; try { categories = dataProvider.requestSeatCategory(Utility.selectedCity, Utility.selectedMovie, Utility.selectedTheatre, Utility.selectedShow); } catch (Exception e) { Utility.showAlert("SeatCategory-Error", "No Data Found", AlertType.ERROR, lstShowTimings); } Font labelFont = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE); for (int i = 0; i < categories.length; i++) { lstSeatCategory.append(categories[i], Utility.img); } for (int i = 0; i < categories.length; i++) { lstSeatCategory.setFont(i, labelFont); } lstSeatCategory.addCommand(new Command("Back", Command.BACK, 0)); lstSeatCategory.setCommandListener(new CommandListener() { public void commandAction(Command cmd, Displayable d) { if (cmd == List.SELECT_COMMAND) { Utility.seatCategory = lstSeatCategory.getString(lstSeatCategory.getSelectedIndex()); disp.setCurrent(getNoOfSeatsScreen(lstSeatCategory)); } else if (cmd.getCommandType() == Command.BACK) { disp.setCurrent(parentScreen); } } }); disp.setCurrent(lstSeatCategory); } public Screen getNoOfSeatsScreen(final Screen parentScreen) { frmSeats = new Form("Total Seats"); final TextField txtSeats = new TextField("Enter no. of seats", "", 2, TextField.NUMERIC); frmSeats.append(txtSeats); frmSeats.addCommand(new Command("Back", Command.BACK, 0)); DDU (Faculty of MIS, Dep. of MCA) 57

frmSeats.addCommand(new Command("Ok", Command.OK, 1)); frmSeats.setCommandListener(new CommandListener() { public void commandAction(Command cmd, Displayable d) { if (cmd.getCommandType() == Command.OK) { Utility.noOfTickets = txtSeats.getString(); showSeatMap(frmSeats); } else if (cmd.getCommandType() == Command.BACK) { disp.setCurrent(parentScreen); } } }); return frmSeats; } public void showSeatMap(final Screen parentScreen) { final Canvas seatMap = new SeatMap(); seatMap.setCommandListener(new CommandListener() { public void commandAction(Command cmd, Displayable d) { if (cmd.getCommandType() == Command.OK) { disp.setCurrent(WaitCanvas.getInstance()); new Thread(new Runnable() { public void run() { try { String resp = dataProvider.submitFinalData(Utility.selectedCity, Utility.selectedMovie, Utility.selectedTheatre, Utility.selectedShow, Utility.seatCategory); if (resp != null) { Utility.referenceId = resp; // Reference Id showReceipt(); } else //error { throw new Exception(); } } catch (Exception e) { Utility.showAlert("Receipt-Error", "System Unable to process request.", AlertType.ERROR, seatMap); } } DDU (Faculty of MIS, Dep. of MCA) 58

}).start(); } else if (cmd.getCommandType() == Command.BACK) { disp.setCurrent(parentScreen); } } }); disp.setCurrent(seatMap); } public void showHistoryForm(final Screen parentScreen) { final Form frmHistory = new Form("History"); final TextField txtRefId = new TextField("Reference No:", "", 10, TextField.NUMERIC); frmHistory.append(txtRefId); frmHistory.addCommand(new Command("Get History", Command.OK, 0)); frmHistory.addCommand(new Command("Back", Command.BACK, 1)); frmHistory.addCommand(new Command("Delete History", Command.CANCEL, 2)); frmHistory.setCommandListener(new CommandListener() { public void commandAction(Command cmd, Displayable d) { if (cmd.getCommandType() == Command.OK) { // View History disp.setCurrent(WaitCanvas.getInstance()); new Thread(new Runnable() { public void run() { try { String resp = dataProvider.viewHistory(txtRefId.getString()); if (resp != null) { showHistory(resp); } else //error { throw new Exception(); } } catch (Exception e) { Utility.showAlert("HistoryView-Error", "System Unable to process request.", AlertType.ERROR, frmHistory); } } }).start(); } DDU (Faculty of MIS, Dep. of MCA) 59

else if (cmd.getCommandType() == Command.BACK) { disp.setCurrent(parentScreen); } else if (cmd.getCommandType() == Command.CANCEL) { disp.setCurrent(WaitCanvas.getInstance()); new Thread(new Runnable() { public void run() { try { String resp = dataProvider.deleteHistory(txtRefId.getString()); if (resp != null) { Utility.showAlert("History", resp, AlertType.INFO, frmHistory); } else //error { throw new Exception(); } } catch (Exception e) { Utility.showAlert("History-Error", "System Unable to process request.", AlertType.ERROR, frmHistory); } } }).start(); } } }); disp.setCurrent(frmHistory); } public void showReceipt() { Form frmReceipt = new Form("Receipt"); StringItem strCity = new StringItem("City", Utility.selectedCity); StringItem strMovie = new StringItem("Movie", Utility.selectedMovie); StringItem strTheatre = new StringItem("Theatre", Utility.selectedTheatre); StringItem strShowTime = new StringItem("ShowTimings", Utility.selectedShow); StringItem strNoOfTickets = new StringItem("Total Tickets", Utility.noOfTickets); StringItem strReferenceId = new StringItem("Reference Id", Utility.referenceId); frmReceipt.append(strCity); frmReceipt.append(strMovie); frmReceipt.append(strTheatre); frmReceipt.append(strShowTime); frmReceipt.append(strNoOfTickets); DDU (Faculty of MIS, Dep. of MCA) 60

frmReceipt.append(strReferenceId); frmReceipt.addCommand(new Command("Ok", Command.OK, 0)); frmReceipt.setCommandListener(new CommandListener() { public void commandAction(Command c, Displayable d) { disp.setCurrent(getWelcomeScreen()); } }); disp.setCurrent(frmReceipt); } private void showHistory(String resp){ Form frmHistory = new Form("History"); String[] data = Utility.Split(resp, '#'); for (int i=0; i<data.length; i++){ frmHistory.append(new StringItem(data[i], "")); frmHistory.append("\n"); } frmHistory.addCommand(new Command("Ok", Command.OK, 0)); frmHistory.setCommandListener(new CommandListener() { public void commandAction(Command c, Displayable d) { disp.setCurrent(getWelcomeScreen()); } }); disp.setCurrent(frmHistory); } private void showHelp(){ Form frmHelp = new Form("HELP"); frmHelp.append(new StringItem(Utility.Help, "")); frmHelp.addCommand(new Command("Ok", Command.OK, 0)); frmHelp.setCommandListener(new CommandListener() { public void commandAction(Command c, Displayable d) { disp.setCurrent(getWelcomeScreen()); } DDU (Faculty of MIS, Dep. of MCA) 61

}); disp.setCurrent(frmHelp); } }

UTILITY MIDLET:

package Code; import java.util.Vector; import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.AlertType; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Image; public class Utility { public static final Display disp = BookShowMidlet.getDispObject(); public static String selectedCity; public static String selectedMovie; public static String selectedTheatre; public static String selectedShow; public static String noOfTickets; public static String seatCategory; public static String referenceId; public static String Help = "This is help1\n This is help2."; public static final Image img = getImage(); public static String[] Split(String source, char del) { Vector vect = new Vector(); if (!source.endsWith(String.valueOf(del))) source += del; StringBuffer sb = new StringBuffer(); for (int i=0; i<source.length(); i++) { if (source.charAt(i) != del) { sb.append(source.charAt(i)); } DDU (Faculty of MIS, Dep. of MCA) 62

else { vect.addElement(sb.toString()); sb.delete(0, sb.length()); } } vect.trimToSize(); String[] splitted = new String[vect.size()]; vect.copyInto(splitted); return splitted; } public static void showAlert(String title, String content, AlertType alertType, Displayable onError){ Alert al = new Alert(title, content, null, alertType); al.setTimeout(Alert.FOREVER); disp.setCurrent(al, onError); } public static Image getImage(){ Image img=null; try{ img = Image.createImage("/Code/new.png"); //imgItem = new ImageItem(null, img, ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_AFTER,""); }catch(Exception e){ System.out.println("image can't be loaded: "+e.getMessage()); } return img; } }

SEATMAP MIDLET:
package Code; import javax.microedition.lcdui.*; public class SeatMap extends Canvas { int H = getHeight(); int W = getWidth(); Graphics gr; int currX; int rowGap = 20; int seatWidth = 15; DDU (Faculty of MIS, Dep. of MCA) 63

int seatHeight = 15; int currY = 75; int seatGap = 3; int seatsInRow = 10; public SeatMap(){ initCurrX(); addCommand(new Command("Ok",Command.OK,0)); addCommand(new Command("Back", Command.BACK,1)); //setFullScreenMode(true); } void initCurrX(){ currX = 25; } protected void paint(Graphics g) { gr = g; g.setColor(255, 255, 255); g.fillRect(0, 0, W, H); // Draw Border g.setColor(0,0,0); g.drawRect(5, 5, W - 10, H - 10); // Draw screen currX -= seatWidth - seatGap; int screenEnd = seatsInRow * (seatWidth + seatGap); initCurrX(); g.setColor(100,100,100); g.fillRoundRect(currX, 15, screenEnd, 15, 10, 10); // Draw "Screen" text g.setColor(255,255,255); g.drawString("SCREEN", (W/2)-20, 15, Graphics.TOP | Graphics.LEFT); // Mark Silver Category g.setColor(131,155,32); g.drawString("SILVER", (W/2)-20, currY-seatHeight-15, Graphics.TOP | Graphics.LEFT); // Draw Seat Row nos g.setColor(0,0,255); initCurrX(); for (int i=0; i<seatsInRow; i++){ DDU (Faculty of MIS, Dep. of MCA) 64

g.drawString(String.valueOf(i+1), currX, currY-seatHeight, Graphics.LEFT | Graphics.TOP); currX += (seatWidth + seatGap); } // Draw Seat Column /*g.setColor(0,0,255); initCurrX(); //currY -= seatHeight; currX -= (seatWidth - seatGap); String[] seatRows = new String[] {"A","B","C","D","E","F","G"}; for (int i=0; i < 7 ; i++){ g.drawString("A", currX, currY, Graphics.LEFT | Graphics.TOP); currY -= rowGap; }*/ // First row initCurrX(); g.setColor(0,0,255); g.drawString("A", currX - seatWidth, currY, Graphics.LEFT | Graphics.TOP); for (int i=0; i < seatsInRow; i++){ drawSeat(currX, false); currX += seatWidth + seatGap; } // Second row initCurrX(); incrementYtoNextRow(); g.setColor(0,0,255); g.drawString("B", currX - seatWidth, currY, Graphics.LEFT | Graphics.TOP); for (int i=0; i < seatsInRow; i++){ drawSeat(currX, false); currX += seatWidth + seatGap; } // Third row initCurrX(); incrementYtoNextRow(); g.setColor(0,0,255); g.drawString("C", currX - seatWidth, currY, Graphics.LEFT | Graphics.TOP); //Mark booked row for (int i=0; i < seatsInRow; i++){ drawSeat(currX, true); DDU (Faculty of MIS, Dep. of MCA) 65

currX += seatWidth + seatGap; } // Fourth row initCurrX(); incrementYtoNextRow(); g.setColor(0,0,255); g.drawString("D", currX - seatWidth, currY, Graphics.LEFT | Graphics.TOP); //Mark booked row for (int i=0; i < seatsInRow; i++){ drawSeat(currX, true); currX += seatWidth + seatGap; } // Fifth row initCurrX(); incrementYtoNextRow(); // Mark Gold Category g.setColor(131,155,32); g.drawString("GOLD", (W/2)-20, currY, Graphics.TOP | Graphics.LEFT); incrementYtoNextRow(); g.setColor(0,0,255); g.drawString("E", currX - seatWidth, currY, Graphics.LEFT | Graphics.TOP); for (int i=0; i < seatsInRow; i++){ drawSeat(currX, false); currX += seatWidth + seatGap; } // Sixth row initCurrX(); incrementYtoNextRow(); g.setColor(0,0,255); g.drawString("F", currX - seatWidth, currY, Graphics.LEFT | Graphics.TOP); for (int i=0; i < seatsInRow; i++){ drawSeat(currX, true); currX += seatWidth + seatGap; } // Sevnth row initCurrX(); incrementYtoNextRow(); g.setColor(0,0,255); g.drawString("G", currX - seatWidth, currY, Graphics.LEFT | Graphics.TOP); for (int i=0; i < seatsInRow; i++){ DDU (Faculty of MIS, Dep. of MCA) 66

drawSeat(currX, false); currX += seatWidth + seatGap; } // Draw Seat legend // Red: Booked int legendsAboveBottom = H - 30 + seatHeight; initCurrX(); currY = H - 30; g.setColor(255,0,0); g.fillRect(currX, H - 30, seatWidth, seatHeight); g.drawString("Booked", currX+seatWidth+3, legendsAboveBottom, Graphics.BOTTOM | Graphics.LEFT); // White: Available currX = (currX + seatWidth + 3 + 70); g.setColor(0,0,0); g.drawRect(currX, currY, seatWidth, seatHeight); g.drawString("Available", currX+seatWidth+3, legendsAboveBottom, Graphics.BOTTOM | Graphics.LEFT); }

private int drawSeat(int currX, boolean isBooked){ if (isBooked) { gr.setColor(255,0,0); gr.fillRect(currX, currY, seatWidth, seatHeight); } else { gr.setColor(0,0,0); gr.drawRect(currX, currY, seatWidth, seatHeight); } return currX; } private void incrementYtoNextRow(){ currY += rowGap; } } DDU (Faculty of MIS, Dep. of MCA) 67

WAITCANVAS MIDLET:
package Code; import javax.microedition.lcdui.*; public class WaitCanvas extends Canvas { int H = getHeight(); int W = getWidth(); Graphics gr; private static WaitCanvas waitCanvas; private WaitCanvas(){ setFullScreenMode(true); } public static WaitCanvas getInstance(){ if (waitCanvas == null) waitCanvas = new WaitCanvas(); return waitCanvas; } protected void paint(Graphics g) { gr = g; // Fill RoundRect g.setColor(208, 88, 36); g.fillRoundRect(20, (H/2)-40, W - 40, (H/2), 20, 20); Font labelFont = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE); // Text color g.setColor(255, 255, 255); g.setFont(labelFont); g.drawString("Please Wait...", 75, H/2, Graphics.LEFT | Graphics.TOP); } }

DDU (Faculty of MIS, Dep. of MCA)

68

SERVLETS:

CATEGORY SERVLET;
import java.io.IOException; import java.io.PrintWriter; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.sql.*; import javax.servlet.http.HttpSession; public class CategoryServlet extends HttpServlet { private Connection c; private Statement stmt; private int reqcnt=0; private PrintWriter out; private ResultSet rs; private StringBuffer s; private String str; private String action; private String city; private String movie; private String theatre; private String showTime; private HttpSession hs; private String str1; private String ScreenList = new String(); private String[] CategoryList = new String[5]; private String ShowList; public void getDatabaseConnection() { s = new StringBuffer(""); str = new String(""); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); c = DriverManager.getConnection("jdbc:odbc:abc");

DDU (Faculty of MIS, Dep. of MCA)

69

stmt = c.createStatement(); } catch(Exception e) { e.printStackTrace(); } } protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException { getDatabaseConnection(); response.setContentType("text/plain;charset=UTF-8"); out = response.getWriter(); hs = request.getSession(); //city = (String)hs.getAttribute("city"); city = request.getParameter("city"); //movie = (String)hs.getAttribute("movie"); movie = request.getParameter("movie"); //theatre = (String)hs.getAttribute("theatre"); theatre = request.getParameter("theatre"); /*showTime = "#"; showTime.concat(request.getParameter("showtime")); showTime.concat("#");*/ showTime = request.getParameter("showtime"); hs.setAttribute("showTime", showTime); int i, j, k, l; i=j=k=l=0; try { s = new StringBuffer("category|"); rs = stmt.executeQuery("SELECT ShowID FROM Show WHERE Time='"+showTime+"'"); while(rs.next()) { ShowList = rs.getString("ShowID"); i++; } rs = stmt.executeQuery("SELECT DISTINCT ScreenID FROM Movie where MovieName ='"+movie+"' and ShowID ='"+ShowList+"'"); DDU (Faculty of MIS, Dep. of MCA) 70

while(rs.next()) { ScreenList = rs.getString("ScreenID"); i++; } i=0; j=0; rs = stmt.executeQuery("SELECT DISTINCT CategoryID FROM Screen where ScreenID ='"+ScreenList+"'"); while(rs.next()) { CategoryList[i] = rs.getString("CategoryID"); i++; } for(k=0;CategoryList[k]!=null;k++) { rs = stmt.executeQuery("SELECT DISTINCT Name FROM Category where CategoryID ='"+CategoryList[k]+"'"); while(rs.next()) { str1 = rs.getString("Name"); s.append(str1+"#"); } } } catch(Exception e) { out.println("Error"); } finally { int length = s.length(); str1 = s.substring(0, length-1); out.println(str1); out.close(); } }

DDU (Faculty of MIS, Dep. of MCA)

71

// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { processRequest(request, response); } catch (SQLException ex) { Logger.getLogger(CategoryServlet.class.getName()).log(Level.SEVERE, null, ex); } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { processRequest(request, response); } catch (SQLException ex) { Logger.getLogger(CategoryServlet.class.getName()).log(Level.SEVERE, null, ex); } } public String getServletInfo() { return "Short description"; } }

7.TESTING
Testing is the process carried out on software to detect the differences between its behavior and the desired behavior as stipulated by the requirements specifications. Testing is advantageous in several ways. Firstly, the defects found help in the process of DDU (Faculty of MIS, Dep. of MCA) 72

making the software reliable. Secondly, even if the defects found are not corrected, testing gives an idea as to how reliable the software is. Thirdly, over time, the record of defects found reveals the most common kinds of defects, which can be used for developing appropriate preventive measures such as training, proper design and reviewing

7.1 TEST PLAN


The testing sub-process includes the following activities in a phase dependent manner: a) b) c) d) e) f) Create Test Plans. Create Test Specifications. Review Test Plans and Test Specifications. Conduct tests according to the Test Specifications, and log the defects. Fix defects, if any. When defects are fixed continue from activity.

UNIT TESTING G
MODULE TESTING

SUB-SYSTEM TESTING

SYSTEM TESTING

TESTING G

ACCEPTANCE TESTING

Fig 7.1.1 Testing Plan

7.2 TESTING STRATEGY


The development process repeats this testing sub-process a number of times for the following phases.

DDU (Faculty of MIS, Dep. of MCA)

73

a) Unit Testing. b) Integration Testing Unit Testing tests a unit of code (module or program) after coding of that unit is completed. Integration Testing tests whether the various programs that make up a system, interface with each other as desired, fit together and whether the interfaces between the programs are correct. System Testing ensures that the system meets its stated design specifications. Acceptance Testing is testing by the users to ascertain whether the system developed is a correct implementation of the Software Requirements Specification. Testing is carried out in such a hierarchical manner to ensure that each component is correct and the assembly/combination of components is correct. Merely testing a whole system at the end would most likely throw up errors in components that would be very costly to trace and fix. We have performed both Unit Testing and System Testing to detect and fix errors. A brief description of both is given below. Unit Testing Objective The objective of Unit Testing is to test a unit of code (program or set of programs) using the Unit Test Specifications, after coding is completed. Since the testing will depend on the completeness and correctness of test specifications, it is important to subject these to quality and verification reviews. Input: Unit Test Specifications Testing Process Checking for availability of Code Walk-thru reports which have documented the existence of and conformance to coding standards. Review of Unit Test Specifications Verify the Unit Test Specifications conform to the program specifications. Verify that all boundary and null data conditions are included.

7.3 TEST CASES:


Test Data Test Condition Expected Result Actual Result 74

DDU (Faculty of MIS, Dep. of MCA)

Application User When the user selects clicks on any city. one desired city from given cities.

Next page will be 1) If user does not select the city displayed which will properly next page will not be show the name of displayed. available movies. 2) If user selects the city name properly next page containing the movie name will be displayed.

Test Data Test Condition Application User When the user selects clicks on any Movie one of the desired movie from given movies.

Expected Result

Actual Result

Next page will be 1) If user does not select the city displayed which will properly next page will not be show the name of displayed. multiplexes. 2) If user selects the movie name properly next page containing the multiplexes name will be displayed.

Test Data Application User selects Multiplex.

Test Condition When the user clicks on any one of the desired multiplex from given multiplexes.

Expected Result Next page will be displayed which gives details of show timing for selected movie in selected multiplex.

Actual Result 1) If user does not select the multiplex properly next page will not be displayed. 2) If user selects the multiplex name properly next page containing the show timings will be displayed. Actual Result 1) If user does not select the show timing properly next page will not be displayed. 2) If user selects the show timing properly next page containing the categories of seats will be 75

Test Data Test Condition Application User When the user selects clicks on any show one of the timing. desired show time from available one.

Expected Result Next page will be displayed which will show user the categories of seat available in selected multiplex.

DDU (Faculty of MIS, Dep. of MCA)

displayed.

Test Data Test Condition Application User When the user selects clicks on any category one of the of seat category of and no of seats from seats. available one.

Expected Result

Actual Result

Next page will be 1) If user does not select the displayed, which will category of seat properly next page show user the seat will not be displayed. layout of multiplex. 2) If user selects the category of seats properly then on availability of seats next page containing the seat layout of multiplex is shown.

7.4 TEST DATA

The following are the test data: Name of city Name of Movie Name of Multiplex Show Timing Category of Seats Numbers of Seats

8. USER MANUAL

WECOME PAGE:

DDU (Faculty of MIS, Dep. of MCA)

76

This is the first page that will appear when user starts this application.

CITY SELECTION:

DDU (Faculty of MIS, Dep. of MCA)

77

Now by selecting the 1st option that is Purchase Ticket user will get the second page with the list of city.

MOVIE SELECTION:
DDU (Faculty of MIS, Dep. of MCA) 78

After selecting the desirable city user will get next page containing the list of available movies.

MULTIPLEX SELECTION:
DDU (Faculty of MIS, Dep. of MCA) 79

After selecting the desirable movie user has to select the desirable Multiplex name form the available list.

SELECTION OF SHOW TIME:

DDU (Faculty of MIS, Dep. of MCA)

80

Now once the Multiplex is selected as per as users choice, the next thing that user has to do is to select the show time for movie and multiplex selected earlier.

CATEGORY OF SEATS:

DDU (Faculty of MIS, Dep. of MCA)

81

On selecting desirable Show Time the next page that user will get is the page that shows the Category of Seats. Now user has to select one of the category form the available categories.

NO OF SEATS:

DDU (Faculty of MIS, Dep. of MCA)

82

Here user has to give the number of seats he wants to book for particular category selected in earlier step.

SEAT LAYOUT:

DDU (Faculty of MIS, Dep. of MCA)

83

After giving the number of seats required, on availability of seats in the selected seat category, a the page showing the Seats Layout will be shown to user for easy understanding and making choice.

RECEIPT GENERATED:
DDU (Faculty of MIS, Dep. of MCA) 84

After completion of all procedure a receipt containing information of all the selection made by the user and also the generated unique reference ID is shown to the user. With this the ticket booking process is completed.

SELECTION TO VIEW HISTORY:


DDU (Faculty of MIS, Dep. of MCA) 85

If user has already booked the ticket then the history of all the selection made by user can be seen by selecting 2nd option from the main welcome page.

PROVIDE REFERENCE ID:

DDU (Faculty of MIS, Dep. of MCA)

86

To view the history information user has to provide the unique Reference ID. A menu containing the option get history and delete history is provided to user.

SELECTION OF HISTORY:

DDU (Faculty of MIS, Dep. of MCA)

87

After the verification of reference id and on Selection of Get History option a page containing all information of all the selection made by the user along with the unique Reference ID is shown to user.

SELECTION OF HELP:
DDU (Faculty of MIS, Dep. of MCA) 88

On selecting help option by the user, the application will provide all the necessary information to use the application.

DDU (Faculty of MIS, Dep. of MCA)

89

DESCRIPTION TO USE THE APPLICATION:

By seeing this description it will be easy for the new users to use the application.

9. FUTURE ENHANCEMENT

DDU (Faculty of MIS, Dep. of MCA)

90

We have display the seat canvas statically but we will try to make it dynamic in future. Right now this application can be deployed only on the stimulator provided by J2ME but in future by makings changes in the application it can be deployed on server space and the application will work as real application.

10. BIBLOGRAPHY
Books:1. The Complete Reference (J2ME) - James Edward Keogh - TATA McGraw Hill 2. Developing Mobile Java Application - Michael Juntao Yuan - Prentice Hall PTR 3. Core Java VOLUME 1 & 2 - CAY S. Horstmann,Gary Cornell 4. Head First Servlets & JSP - Bryan Basham - Kathy Sierra -Bert Bates - O'Reilly Publication

DDU (Faculty of MIS, Dep. of MCA)

91

Você também pode gostar