THE UNIVERSITY OF DANANG DANANG UNIVERSITY OF SCIENCE AND TECHNOLOGYFACULTY OF INFORMATION TECHNOLOGY GRADUATION PROJECT THESIS INFORMATION TECHNOLOGY FACULTY PROJECT TITLE: RAILWAY
Trang 1THE UNIVERSITY OF DANANG DANANG UNIVERSITY OF SCIENCE AND TECHNOLOGY
FACULTY OF INFORMATION TECHNOLOGY
GRADUATION PROJECT THESIS
INFORMATION TECHNOLOGY FACULTY
PROJECT TITLE:
RAILWAY TICKET BOOKING SYSTEM USING
QR CODE
Trang 2THE UNIVERSITY OF DANANG DANANG UNIVERSITY OF SCIENCE AND TECHNOLOGY
FACULTY OF INFORMATION TECHNOLOGY
GRADUATION PROJECT THESIS
INFORMATION TECHNOLOGY FACULTY
PROJECT TITLE:
RAILWAY TICKET BOOKING SYSTEM USING
QR CODE
Da Nang, 12/2018
Trang 3INSTRUCTOR’S COMMENTS
Trang 4
REVIEWER’S COMMENTS
Trang 5
ABSTRACT
Project name: Railway ticket booking system usong QR code
Student: Ho Nguyen Truc Vy Student ID: 102140201 Class: 14TCLC1
Summary: This paper deals with the Android application for ticket reservation
and validation using mobile tower network One of the major challenges in the current ticketing facility is buying ticket standing in the queue This application provides the facility for buying the tickets online The ticket can be bought with the help of Smartphone application where the railway tickets are carried in the phone in the form of quick response code The ticketing information of the user is stored in the database This system uses the Smartphone facility to validate the ticket and delete it after a specific interval of time once the user reaches the destination This application also includes the automatic fine deduction facility if the user tries to extend the journey Also the ticket checker is provided with the checker application which is used for the validation of the ticket As soon as the passenger gets down from the train or metro users ticket will be automatically deleted from the Smartphone So the user cannot use this ticket again for travelling This system suggests a user-friendly automated ticketing system which will automatically deduct the passengers fare according to the distance traveled as well as detect the passenger's identification and deals with the identification and ticketing of the passengers sitting in the train
Trang 6THE UNIVERSITY OF DANANG
UNIVERSITY OF SCIENCE AND
TECHNOLOGY
INFORMATION TECHNOLOGY
FACULTY
SOCIALIST REPUBLIC OF VIET NAM
Independence – Freedom – Happiness
GRADUATION PROJECT REQUIREMENTS
Student Name: …….……….……….……… Student No.: ………
Class: ………Department: ……… Major: ………
1 Name of project:
This project’s results: ☐ Are protected by an intellectual property agreement 2 Initial data:
3 Project contents:
4 Charts and drawings (please specify the drawing type and size):
Supervisor(s): …
5 Date of assignment: ………/… /201…
6 Date of completion: … /……./201…
Da Nang, day month year 201
Head of Division Supervisor(s)
Trang 7i
ACKNOWLEDGEMENTS
After an intensive period of four months, today is the day: writing this note of thanks is the finishing touch on our senior project It has been a period of intense learning for me I would like to reflect on the people who have supported and helped me so much throughout this period
I would first like to thank my supervisors, PhD Nguyen Van Hieu for his
continuous support, supervision, motivation, and guidance throughout the tenure of my project in spite of their hectic schedule They remained a driving spirit in our project and their experience gave us the understanding in handling research projects as well as helping me to clarify the abstruse concepts, requiring knowledge and perception, handling critical situations and in understanding the objective of our work
I also want to thanks my families and friends, who gave us the strength and confidence during my time of learning and during the implementation phase of this project They have given a lot of love and encouragement for me which helped pass over the difficulties and fatigues
Without your generous help, my senior year would not have been successful
Trang 9
iii
TABLE OF CONTENT
Instructor’s comments
Response’s comments
Abstract
Graduation project requirements
Acknowledgements i
Guarantee ii
Table of content iii
List of tables and figures v
List of symbols and abbreviations ix
Chapter 1: THEORITICAL FOUNDATION 3
1.1 Architectural Design of system 3
1.1.1 QR code 3
1.1.2 Java programing language 6
1.1.4 RESTful Programming 9
2.1 Main features 11
2.1.1 Ticket booking 11
2.1.2 Search train schedule 11
2.1.3 QR code generation 11
2.1.4 Payment integration 11
2.2 User case diagram 11
2.2.1 Use-case diagram of customer 11
2.2.1 Description for main use-case 13
2.2.3 Database diagram 17
2.2.4 Sequence diagram 21
3.2.2 Register 27
3.2.3 Search schedule 28
3.2.4 Reveser seat 33
3.2.5 Booking ticket 35
3.2.6 Show ticket detail 37
CONCLUSION 39
REFERENCES 40
Trang 10iv
Trang 11v
LIST OF TABLES, PICTURES
1 List of figures
Figure 1.4: QR code supported formats 5
Figure 2.1: Use-case diagram of customer 12
Figure 2.3: Sequence diagrams for search train schedule by station function 22
Figure 2.3: Sequence diagrams for search train schedule by code function 22
Figure 2.3: Sequence diagrams for add seat to seat storage function 23
Figure 2.3: Sequence diagrams for delete seat from seat storage function 23
Figure 2.3: Sequence diagrams for booking function 24
Figure 2.3: Sequence diagrams for payment function 24
2 List of tables Table 2.1: User 18
Table 2.2: Seat storage 18
Table 2.3: Ticket 19
Table 2.4: Train 19
Table 2.5: Carrage 19
Table 2.6: Seat 19
Table 2.7: Carrage fare 20
Table 2.8: Train schedule 20
Table 2.9: Station 20
Table 2.10: Station per journey 20
Table 2.11: Seat status 21
Trang 12vi
LIST OF SYMBOLS AND ABBREVIATIONS
1 Abbreviations
No Items Description
1 SQL Structured Query Language
2 SDK Software Development Kit
3 API Application Programming Interface
4 OOP Object Oriented Programming
5 MVC Model View Controller
6 JDK Java Development Kit
7 REST Representational State Transfer
8 HTTP HyperText Transfer Protocol
9 XML Extensible Markup Language
10 JSON JavaScript Object Notation
11 ORM Object Relational Mapping
12 OXM Object XML Mappers
13 JMS Java Message Service
14 AOP Aspect Oriented Programming
15 JDBC Java Database Connectivity
16 EJB Enterprise JavaBeans
Trang 13INTRODUCTION
Project Overview
In fast-forward world of technology, everyone is running behind time Thus the main motivation of technology is producing time and cost efficient product Since mobile phones have become pervasive in our lives, until now, the use of mobile phones has been limited Both consumers and marketers have craved for an application that allows them to effectively use the cell phone in their pockets for something more than just calling people, taking a spur of the moment for some entertainment Efforts are being made to develop applications that can use the mobile phone as a payment instrument for ticketing, such application will play an even important role in a heavily populated country like Vietnam thereby allowing the people to save a lot of time by avoiding never-ending queues The ticket can be bought with the help of a smartphone application, where your railway tickets can be carried in your phone
Purpose
The objective of this project is to develop an android application which will serve
as the medium for students/employees/anyone to book a ticket to travel through metros
or locals The main motive of the application is to ease the process of ticket booking by avoiding the hectic process to stand in the queue and book the ticket for traveling on the train There are several applications available in the market giving the information about the traveling destinations and their fares But none of these applications include the ticket booking process Moreover, the tickets book on the websites has to be saved and printed so as to be shown at the time of boarding Whereas, this application differs as it would not only book the tickets but also save the ticket in the form of QR code
This QR code can be scanned through the other mobiles andsaved as well which can be shown to the ticket checker for validation Apart from the validation and reservation of ticket, this paper proposed a system for the fine deduction wherein if the traveler tries to extend the journey then the destination will be traced through the mobile tower and the fine will be automatically deducted from the user account The data about the ticket and personal information will be securely stored onto the database Also, the user's application would require the user to create an account so that it can be used by multiple users and would be independent of devices The user can log in to any mobile
Trang 14device having the application installed For buying the tickets the user select source, destination class number of adult and child tickets ticket type like single and source etc
Theories structure
The thesis is organized as follows:
Introduction
Chapter 1: Theoritical foundation
Chapter 2: Proposed solution
Chapter 3: Implementation and experiment
Conclution
Referrences
Trang 15Chapter 1: THEORITICAL FOUNDATION
1.1 Architectural Design of system
1.1.1 QR code
Figure 1.1: QR code
A QR code is any code that users find on most of any items that they buy from the store QR codes have come a long way and now that they are integrated into the online world it’s a true phenomenon It makes searching for online products, shopping and buying much easier Now, users are going to use it for buying tickets Creates an image
in real world and acts like a web link for the smart phones It actually grabs the code scans the item and goes online searches for the item which then give users so many details about the product The user gets specific details as per user choice and reviews about the product you have just scanned from the scanner When user scans a QR code
a magazine, a newspaper or wherever the iPhone or Android will to go to a website where the user will find much of promos, coupons, maps and many more information
QR codes now are used in a much broader context, including both business tracking applications and convenience-oriented applications aimed at mobile phone users, to open a Uniform Resource Identifier (URI), or to compose an e-mail or text message Users can generate and print their own QR codes for others to scan and use by visiting one of several paid and free QR code generating websites or applications It has then become one of the most-used types of two-dimensional barcode
QR code Encryption
Encrypted QR codes are QR codes that not everyone can scan and access They are not very common, since most QR codes are used in marketing, and the developers of
Trang 16those codes want them to be accessible by everyone Secure QR codes can be made that make the scanner enter a password to be able to access the content This is a good idea
to make for employees of a company The company can make secure QR codes that the employee has to enter the company password to view This means people outside of the company cannot see decode the QR code without the password One Android app can encrypt and decrypt QR codes using the DES algorithm The immigration department
of Japan has used encrypted QR codes on visas
QR codes are normally encoded in plaintext A QR code must contain certain parts
to be easily decoded This article, Anatomy of a QR Code, breaks down the different parts of a QR code There must be the four main squares that you can see in a QR code, two in the upper corners, one in the lower left corner, and a smaller one near the lower right corner, which contains information on the alignment pattern There also must be white space around the outside of the QR code This is called the quiet zone Check out the image below to learn more about parts of the QR code
Figure 1.2: How QR code work?
QR code Encoding
The format information records two things: the error correction level and the mask pattern used for the symbol Masking is used to break up patterns in the data area that might confuse a scanner, such as large blank areas or misleading features that look like the locator marks The mask patterns are defined on a grid that is repeated as necessary
to cover the whole symbol Modules corresponding to the dark areas of the mask are
Trang 17inverted The format information is protected from errors with a BCH code, and two complete copies are included in each QR symbol
The message dataset is placed from right to left in a zigzag pattern, as shown below In larger symbols, this is complicated by the presence of the alignment patterns and the use
of multiple interleaved error-correction blocks
Figure 1.3: QR code encoding
Zxing library
Zxing (short for "zebra crossing") is an open source code library, which handles a variety of 1-dimensional and 2-dimensional barcodes, installed in Java and other languages
Figure 1.4: QR code supported formats
Trang 181.1.2 Java programing language
1.1.2.1 Introduction
Java is a general-purpose computer-programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible It is intended to let application developers "write once, run anywhere" (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture As of 2016, Java is one of the most popular programming languages in use, particularly for client-server web applications, with a reported 9 million developers Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle Corporation) and released in
1995 as a core component of Sun Microsystems' Java platform The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them
1.1.2.2 Features of Java programing language
Java is platform independent
Java was built with the philosophy of "write once, run anywhere" (WORA) The Java code (pure Java code and libraries) you write on one platform (operating system) will run on other platforms with no modification
To run Java, an abstract machine called Java Virtual Machine (JVM) is used The JVM executes the Java bytecode Then, the CPU executes the JVM Since all JVMs works exactly the same, the same code works on other operating systems as well, making Java platform-independent
An object-oriented Language
There are different styles of programming The object-oriented approach is one of the popular programming styles In object-oriented programming, a complex problem is divided into smaller sets by creating objects This makes your code reusable, has design benefits, and makes code easier to maintain
Many programming languages including Java, Python, and C++ has object-oriented features If you are serious about programming, you should definitely learn object-oriented style of programming
Trang 19Java is fast
The earlier versions of Java were criticized for being slow However, things are completely different now The new JVMs are significantly faster And, the CPU that
executes JVM are also getting more and more powerful
Now, Java is one of the fastest programming languages Well optimized Java code is nearly as fast as lower level languages like C/C++, and much faster than Python, PHP etc
Java is secure
The Java platform provides various features for security of Java applications Some
of the high-level features that Java handles are:
Provides secure platform for developing and running applications
Automatic memory management, reduces memory corruption and vulnerabilities
Provides secure communication by protecting the integrity and privacy of data transmitted
Large Standard Library
One of the reasons why Java is widely used is because of the availability of huge standard library The Java environment has hundreds of classes and methods under different packages to help software developers like us For example,
- java.lang - for advanced features of strings, arrays etc
- java.util - for data structures, regular expressions, date and time functions etc
- java.io - for file i/o, exception handling etc
1.1.3 Spring Boot
What is Spring boot?
All in all Spring boot is a project which is built on the top of the Spring framework
It provides a much simpler and faster way to set up, configure and run both simple and web-based applications
Trang 20Figure 1.5: Overview of the Spring Framework
In the Spring core framework, you need to configure all the things for yourself Hence, you can have a lot of configuration files, such as XML descriptors That’s one out of the main problems that Spring Boot solves for you
It smartly chooses your dependencies, auto-configures all the features you will want to use, and you can start your application with one click Furthermore, it also simplifies the deployment process of your application
It can be a bit frightening for a few of you, because it seems that there a lot of
“magic” things happening in the background Despite that, I will explain the best features of the framework I hope you take the advantage of this additional knowledge
on Spring Boot in your future projects It really makes your life simpler
Let’s see the notable features that make it unique and easy to use
on the button or give out the run command, and it will start
Opinionated: This means that the framework chooses how to things for itself This
is the point where a lot of people says "wait a minute, I do not want to participate in it."
Trang 211.1.4 RESTful Programming
RESTFul web services
A web service is a collection of open protocols and standards used for exchanging data between applications or systems Software applications written in various
programming languages and running on various platforms can use web services to exchange data over computer networks like the Internet in a manner similar to inter-process communication on a single computer This interoperability (e.g., between Java and Python, or Windows and Linux applications) is due to the use of open standards
Web services based on REST Architecture are known as RESTful web services These webservices uses HTTP methods to implement the concept of REST architecture A RESTful web service usually defines a URI, Uniform Resource Identifier a service, provides resource representation such as JSON and set of HTTP Methods
HTTP methods
Following four HTTP methods are commonly used in REST based architecture
GET − Provides a read only access to a resource
POST − Used to create a new resource
DELETE − Used to remove a resource
PUT − Used to update a existing resource or create a new resource
Trang 22Following are some important points to be considered while designing a
representation format of a resource in RESTful Web Services
- Understandability − Both the Server and the Client should be able to understand and utilize
the representation format of the resource
- Completeness − Format should be able to represent a resource completely For example, a
resource can contain another resource Format should be able to represent simple as well as complex structures of resources
- Linkablity − A resource can have a linkage to another resource, a format should be able to
handle such situations
HTTP Request
An HTTP Request has five major parts −
Verb − Indicates the HTTP methods such as GET, POST, DELETE, PUT, etc
URI − Uniform Resource Identifier (URI) to identify the resource on the server
HTTP Version − Indicates the HTTP version For example, HTTP v1.1
Request Header − Contains metadata for the HTTP Request message as key-value pairs For example, client (or browser) type, format supported by the client, format of the message body, cache settings, etc
Request Body − Message content or Resource representation
HTTP Response
An HTTP Response has four major parts :
Status/Response Code − Indicates the Server status for the requested resource
For example, 404 means resource not found and 200 means response is ok
HTTP Version − Indicates the HTTP version For example HTTP v1.1
Response Header − Contains metadata for the HTTP Response message as
keyvalue pairs For example, content length, response date, server type, etc
Response Body − Response message content or Resource representation
Trang 23CHAPTER 2: ANALYSIS AND DESIGN 2.1 Main features
2.1.2 Search train schedule
The application offers two ways for the user to search the expected train schedule, one
by the schedule information as: station, time, and another using the train schedule code which helps the customer to look up for the train schedule
2.1.3 QR code generation
This task is handled by the ticket checker The ticket checker is given the QR validation software by which he can check and scan the QR code The ticket checker clicks the image of the code and then scans The information that is stored in the database is then compared with the QR code and the ticket is validated Once the ticket is validated and reached the destination the ticket info is been deleted from the SQL server database
2.1.4 Payment integration
The system has a payment integration function This function supports many popular payment methods such as credit card, debit card, paypal balance It helps customer to payment easily and fast This function is supported by paypal, the biggest company about payment online so it is very safe and have most user in the whole world
2.2 User case diagram
2.2.1 Use-case diagram of customer
Trang 24Figure 2.1: Use-case diagram of customer
Trang 252.2.1 Description for main use-case
User case ID UC-01
Brief description User wants to add a seat to seat storage
Pre-conditions User has already logged in successfully, user also do search a trainschedule Post-conditions Back to All Reserve Seat screen and show notification
storage
User case ID UC-02
Brief description User wants to delete a seat
Pre-conditions User has already logged in successfully
Trang 26Post-conditions Display All Seat Storage pop up dialog after refresh the list and show notification
Flow of activities
1 Click SEAT STORAGE button on Train Diagram Screen
2
Display all Seat Storage pop up dialog
3 Click on the Delete image button on the seat user want to
delete
4
Storage pop up dialog after refresh the list
User case ID UC-03
1 Click BOOKING button on Main Screen
3 Choose one of two ways to search
Fill the requirements
4
schedule screen which suit the requirements