Flight Reservation System
-
Upload
ishant-bhalla -
Category
Documents
-
view
44 -
download
1
description
Transcript of Flight Reservation System
Flight Reservation System
Submitted in partial fulfillment of the requirement
for the award of the degree of
Bachelor of Technology
In
Computer Science & Engineering
Supervisor: Submitted by
Mrs. Bhawana Name: Ishant Bhalla
(A.P., CSE/IT Dept.) Roll no. 10158
PDM College of Engineering
Sarai Aurangabad
Bahadurgarh – 124507 Haryana, INDIA
Session 2012
Certificate
This is to certify that the Seminar Report entitled “Flight Reserevation System”
done by Mr. Ishant Bhalla, Roll No.10158 is an authentic work carried out by him
at PDM under my guidance. The matter embodied in this report has not been
submitted earlier for the award of any degree or diploma to the best of my knowledge
and belief.
.
Mrs. Bhawana
PDM College of Engineering
Sarai Aurangabad
Bahadurgarh – 124507 Haryana, INDIA
Acknowledgements
This Seminar/Project report, while an achievement that bears my name,
would not have been possible without the help of others. I am glad to take this
opportunity to thank the people who helped me to make this work possible.
Firstly, I would like to sincerely thank my Supervisor Mrs. Bhawana
PDMCE, for her able guidance. Her suggestions, recommendations and comments
were invaluable for this report. The report would not have been possible without her
constant support and belief in my capabilities.
I owe my gratitude to her for showing me the right direction that guided me
to overcome the problems I faced during my report work. In spite of his busy
schedule, She patiently listened to my doubts and shared her valuable knowledge.
It has been my privilege to study at P.D.M College Of Engineering , MDU,
Rohtak, which is one of the leading technology schools in India. I am highly grateful
to the honorable Principal PDMCE, Dr. Paramjeet for his ever helping attitude
and encouraging us to excel in studies.
I would like to express my warm gratitude to my family for their love and
support. Finally, I would like to thank all my batch-mates for motivating me and
helping me with sincerity and patience.
Ishant Bhalla
ABSTRACT
The main purpose of this project is to develop an application which can be used to
check the person’s knowledge in java. The application developed enables the client
to practice and improve his/her programming in java. This application can be used in
various organizations where the employees are required to have a deep knowledge in
java. Individual person can also use the application to check his/her concepts. The
application developed was tried and tested on a number of persons and the results
showed that it is a useful application . People also used it to practice and improve
their concepts in core java .
INDEX
Title
Certificate
Acknowledgement
Abstract
List of Abbreviations
List of Figures
Introduction to Java
Versions
Characteristics
Java Platform
Implementations
Performance
Automatic Memory Management
About Course
Course Overview
Course Goals
Project
Source Code
Screen Shots
Conclusion
References and Bibliography
LIST OF ABBREVIATIONS
Abbreviation Meaning
JVM Java Virtual Machine
JDK Java Development Kit
JRE Java Runtime Environment
J2SE Java 2 platform, Standard Edition
GUI Graphical User Interface
I/O Input/output
GNU GNU’s Not Unix
IDE Integrated Development Environment
LIST OF FIGURES
Fig. 1
Fig. 2
Fig. 4
Fig. 3
INTRODUCTION TO JAVA
Java(see logo in Fig. 1) is a programming language originally developed by James
Gosling at Sun Microsystems (which has since merged into 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 has a simpler object
model and fewer low-level facilities than either C or C++. Java applications are
typically compiled to bytecode (class file) that can run on any Java Virtual
Machine (JVM) regardless of computer architecture. Java is a general-
purpose, concurrent, class-based, object-oriented language that is specifically
designed to have as few implementation dependencies as possible. It is intended to
let application developers "write once, run anywhere" (WORA), meaning that code
that runs on one platform does not need to be recompiled to run on another.
The original and reference implementation Java compilers, virtual machines,
and class libraries were developed by Sun from 1991 and first released in 1995. As
of May 2007, in compliance with the specifications of the Java Community Process,
Sun relicensed most of its Java technologies under the GNU General Public License.
Others have also developed alternative implementations of these Sun technologies,
such as the GNU Compiler for Java and GNU Classpath.
Versions
Major release versions of Java, along with their release dates:
JDK 1.0 (October 1, 1992)
JDK 1.1 (February 19, 1997)
J2SE 1.2 (December 8, 1998)
J2SE 1.3 (May 8, 2000)
J2SE 1.4 (February 6, 2002)
J2SE 5.0 (September 30, 2004)
Java SE 6 (December 11, 2006)
Java SE 7 (July 28, 2011)
Characteristics
Java is simple
Java is object-oriented
Java is distributed
Java is interpreted
Java is robust
Java is secure
Java is architecture-neutral
Java is portable
Java’s performance
Java is multithreaded
Java is dynamic
Java Platform
One characteristic of Java is portability, which means that computer programs
written in the Java language must run similarly on any hardware/operating-system
platform. This is achieved by compiling the Java language code to an intermediate
representation called Java bytecode, instead of directly to platform-specific machine
code (see Fig. 2). Java bytecode instructions are analogous to machine code, but are
intended to be interpreted by a virtual machine (VM) written specifically for the host
hardware. End-users commonly use a JRE installed on their own machine for
standalone Java applications, or in a Web browser for Java applets.
Standardized libraries provide a generic way to access host-specific features such as
graphics, threading, and networking.
A major benefit of using bytecode is porting. However, the overhead of
interpretation means that interpreted programs almost always run more slowly than
programs compiled to native executables would. Just-in-Time (JIT) compilers were
introduced from an early stage that compiles bytecode to machine code during
runtime.
Implementations
Oracle Corporation is the current owner of the official implementation of the Java SE
platform, following their acquisition of Sun Microsystems on January 27, 2010. This
implementation is based on the original implementation of Java by Sun. The Oracle
implementation is available for Mac OS X, Windows and Solaris. Because Java lacks
any formal standardization recognized by Ecma International, ISO/IEC, ANSI, or
other third-party standards organization, the Oracle implementation is the de facto
standard.
The Oracle implementations are packaged into two different distributions. The Java
Runtime Environment (JRE) which contains the parts of the Java SE platform
required to run Java programs. This package is intended for end-users. TheJava
Development Kit (JDK), is intended for software developers and includes
development tools such as the Java compiler, Javadoc, Jar, and a debugger.
OpenJDK is another notable Java SE implementation that is licensed under the GPL.
The implementation started when Sun began releasing the Java source code under
the GPL. As of Java SE 7, OpenJDK is the official Java reference implementation.
The goal of Java is to make all implementations of Java compatible. Historically,
Sun's trademark license for usage of the Java brand insists that all implementations
be "compatible". This resulted in a legal dispute with Microsoft after Sun claimed
that the Microsoft implementation did not support RMI or JNI and had added
platform-specific features of their own. Sun sued in 1997, and in 2001 won a
settlement of US$20 million, as well as a court order enforcing the terms of the
license from Sun. As a result, Microsoft no longer ships Windows with Java.
Platform-independent Java is essential to Java EE, and an even more rigorous
validation is required to certify an implementation. This environment enables
portable server-side applications.
Performance
Programs written in Java have a reputation for being slower and requiring more
memory than those written in C. However, Java programs' execution (see Fig. 3)
speed improved significantly with the introduction of Just-in-time compilation in
1997/1998 for Java 1.1, the addition of language features supporting better code
analysis (such as inner classes, the StringBuffer class, optional assertions, etc.), and
optimizations in the Java Virtual Machine itself, such as HotSpot becoming the
default for Sun's JVM in 2000. As of February 2012, micro benchmarks show Java 7
is approximately 1.5 times slower than C.
Some platforms offer direct hardware support for Java; there are microcontrollers
that can run Java in hardware instead of a software Java Virtual Machine,
and ARM based processors can have hardware support for executing Java bytecode
through their Jazelle option.
Automatic Memory Management
Java uses an automatic garbage collector to manage memory in the object lifecycle.
The programmer determines when objects are created, and the Java runtime is
responsible for recovering the memory once objects are no longer in use. Once no
references to an object remain, the unreachable memory becomes eligible to be freed
automatically by the garbage collector. Something similar to a memory leak may still
occur if a programmer's code holds a reference to an object that is no longer needed,
typically when objects that are no longer needed are stored in containers that are still
in use. If methods for a nonexistent object are called, a "null pointer exception" is
thrown.
One of the ideas behind Java's automatic memory management model is that
programmers can be spared the burden of having to perform manual memory
management. In some languages, memory for the creation of objects is implicitly
allocated on the stack, or explicitly allocated and deallocated from the heap. In the
latter case the responsibility of managing memory resides with the programmer. If
the program does not deallocate an object, a memory leak occurs. If the program
attempts to access or deallocate memory that has already been deallocated, the result
is undefined and difficult to predict, and the program is likely to become unstable
and/or crash. This can be partially remedied by the use of smart pointers, but these
add overhead and complexity. Note that garbage collection does not prevent "logical"
memory leaks, i.e. those where the memory is still referenced but never used.
Garbage collection may happen at any time. Ideally, it will occur when a program is
idle. It is guaranteed to be triggered if there is insufficient free memory on the heap
to allocate a new object; this can cause a program to stall momentarily. Explicit
memory management is not possible in Java.
Java does not support C/C++ style pointer arithmetic, where object addresses and
unsigned integers (usually long integers) can be used interchangeably. This allows
the garbage collector to relocate referenced objects and ensures type safety and
security.
As in C++ and some other object-oriented languages, variables of Java's primitive
data types are not objects. Values of primitive types are either stored directly in fields
(for objects) or on the stack (for methods) rather than on the heap, as commonly true
for objects (but see Escape analysis). This was a conscious decision by Java's
designers for performance reasons. Because of this, Java was not considered to be a
pure object-oriented programming language. However, as of Java
5.0, autoboxing enables programmers to proceed as if primitive types were instances
of their wrapper class.
Java contains multiple types of garbage collectors. By default, HotSpot uses
the Concurrent Mark Sweep collector, also known as the CMS Garbage Collector.
However, there are also several other garbage collectors that can be used to manage
the Heap. For 90% of applications in Java, the CMS Garbage Collector is good
enough.
ABOUT COURSE
Course Overview
The course first describes the Java runtime environment and the syntax (see Fig. 4)
of the Java programming language. The course then covers object oriented concepts
as they apply to the Java programming language. As the course progresses, advanced
features of the Java platform are discussed.
While the Java programming language is operating-system-independent, the GUI
that it produces can be dependent on the operating system on which the code is
executed. In this course, code examples are run in the Microsoft Windows operating
environment; therefore, the graphics have a Windows GUI.
Course Goals
Create Java technology applications that leverage the object-oriented features
of the Java language, such as encapsulation, inheritance and polymorphism
Execute a Java technology application from the command line
Use Java technology data types and expressions
Use array and other data collections
Implement error-handling techniques using exception handling
Create an event-driven GUI by using Java technology GUI components:
panels, buttons, text fields, and text areas
Implement I/O functionality to read from and write to data and text files
Create multithreaded programs
CONCLUSION
The project’s main goal was to create an application that can determine a person’s
knowledge . In order to achieve this CORE JAVA Technology was used which
included basic GUI windows and frames. Net Beans IDE was used to develop and
execute the application.
The project illustrated the power of Java technology in creation of web services. The
power was enhanced by the simplicity and effectiveness of the technology. It also
depicted the relative ease with java communicates with other technologies. The
transparency into the micro-operations of the language is a great learning
extravaganza.
REFERENCES AND BIBLIOGRAPHY
Book References
The Complete Reference by Herbert Schildt
Head First Java by Kathy Sierra and Bert Bates
Web References
www.google.com
www.wikipedia.com
SOURCE CODE
flightResDetails.java
package frm; //using for importing the date class. public class flightResDetails extends FlightDetails { String Name; String Address; int phone; String Email; final String[] ReservationType = {"FirstClass","SecondClass","ThirdClass"}; String Res; int Num_OfResSeats; public flightResDetails() { super(); } public flightResDetails(String fNum,String name,String address,int ph,String email,int n,int nseats) { this.Flight_Num = fNum; this.Name = name; this.Address = address; this.phone = ph; this.Email = email; this.Res =ReservationType[n-1]; this.Num_OfResSeats = nseats; } @Override public void setFlightNum(String flightNum) { this.Flight_Num = flightNum; } public void setName(String Name1) { this.Name = Name1; } public void setAddress(String add) { this.Address = add; }
public void setPhone(int ph) { this.phone = ph; } public void setEmail(String email) { this.Email = email; } public void setReservationType(int n) { this.Res = ReservationType[n-1]; } public void setReserveSeats(int n) { this.Num_OfResSeats = n; } }//end of Class
FlightMenu.java
package frm; //core Java packages import java.util.*; // start of class definition public class flightMenu //extends mainSystem { static Vector fDetails = new Vector(); // creating a vector names as fDetails static ManageVector manage = new ManageVector("sample.txt") ; // creating object of ManageVector class static Vector fResDetails = new Vector(); // creating another vector named as fResDetails static ManageVector res = new ManageVector("res.txt"); // creating another object of ManageVector class // start of method AddDetails private static void AddDetails(String flightnum,String flightdate,String flighttime,int numseats,String flightsource, String flightdest) { FlightDetails temp = new FlightDetails(flightnum,flightdate,flighttime,numseats,flightsource,flightdest); fDetails.addElement(temp); System.out.println("Entry Has Been Made"); } //end of method public static void displayAllPass() // start of method { flightResDetails temp2; //declaring object for flightResDetails class fResDetails = res.loadVector(); // loading vector of fResDetails System.out.println("--Flight No.--Name--Address--Phone No.--Email Add-Resv Type--Seats Reserved"); System.out.println(""); for(int i = 0; i<fResDetails.size();i++) // start of for loop { temp2 =(flightResDetails)fResDetails.elementAt(i); System.out.println(temp2.Flight_Num+"--"+temp2.Name+"--"+temp2.Address+"--"+temp2.phone+"--"+temp2.Email+"--"+temp2.Res+"--"+temp2.Num_OfResSeats); } // end of for loop } // end of method
public static void AddMenu() throws java.io.IOException // start of method { // declaring variables String fn; String fd; String ft; int ns; String s; String d; System.out.println(" Please Enter The Following Information ? "); // message asking manager to enter information System.out.println(""); System.out.print(" Enter Flight Number : "); // asking for flight number fn = read.GetString(); // prompt for flight number System.out.print(" Enter Flight Date : "); // asking for flight date fd = read.GetString(); // prompt for flight date System.out.print(" Enter Flight Time : "); // asking for flight time ft = read.GetString(); // prompt for flight time System.out.print(" Enter Number of Seats On Flight : "); // asking for seats on flight ns = read.GetInt(); // prompt for seats on flight System.out.print(" Enter The Source Of the Flight : "); // asking for flight source s = read.GetString(); // prompt for flight source System.out.print(" Enter the Destination of the Flight : "); // asking for flight destination d = read.GetString(); // prompt for flight destination AddDetails(fn,fd,ft,ns,s,d); } // end of method
// start of method displayAll that display all the flight information public static void displayAll() { FlightDetails temp; // declaring object of class FlightDetails System.out.println("-- Flight No.-- Flight Date -- Flight Time -- Seats Resv -- Source -- Dest"); // displaying heading for flight information menu System.out.println(""); for(int i = 0; i<fDetails.size();i++) // start of for loop { temp =(FlightDetails)fDetails.elementAt(i); System.out.println("-- "+temp.Flight_Num+" -- "+temp.FlightDate+" -- "+temp.Time+" -- "+temp.Num_Of_Seats+" -- "+temp.Source+" -- "+temp.Destination); // display menu information } // end of for loop } // end of method // method to delete the flight details private static void delDetails(int index) // start of method { fDetails.removeElementAt(index); // deleting elements from the index System.out.print("Entry Deleted"); // message that entry has been deleted } // end of method public static void delMenu() throws java.io.IOException // start of method { String num; // declaring variable FlightDetails temp = new FlightDetails(); // creating object of class FlightDetails System.out.println("Please Enter Flight Number To Delete"); // message to enter flight number num = read.GetString(); // prompt for flight number for(int i = 0; i<fDetails.size();i++) // start of for loop { temp =(FlightDetails)fDetails.elementAt(i); if(temp.Flight_Num.equals(num)) // if flight number is found { delDetails(fDetails.indexOf(temp)); // calling method delDetails } // end of if statement } // end of for loop if(temp == null) // if the input given is emtpy, then { System.out.println("Entry Not Found");
// message that entry has not been found System.out.println(""); } else { System.out.print("Entry Found"); // message that entry has not been found } } //end of method //Method to save Entries public static void saveEntry() // method to save the entries { manage.saveVector(fDetails); // saving flight details System.out.println(); System.out.println(); System.out.println(" Your Entries For Today Have Been Saved!"); // display message that the entries has been saved uptill now. } // end of method public static void loadEntry() // method to load the flight entries { fDetails = manage.loadVector(); // loading flight details System.out.println(); System.out.println(); System.out.println("Your Entries Been Loaded!"); // display message that the entries has been loaded } // end of method // method to update the flight number public static void updateEntry(String flightnum) throws java.io.IOException { FlightDetails temp = new FlightDetails(); // creating object for Flight Details FlightDetails temp2; // declaring another object of class Flight Details int input; // declaring variable for(int i=0;i<fDetails.size();i++) // start of for loop { temp = (FlightDetails)fDetails.elementAt(i); if(temp.Flight_Num.equals(flightnum)) // start of if statement { temp =(FlightDetails)fDetails.elementAt(i);
temp2 =(FlightDetails)fDetails.elementAt(i); } } System.out.println("\n ... Please Choose The Attribute You want to Change ? "); System.out.println("\n 1. Flight Number"); System.out.println(" 2. Flight Date"); System.out.println(" 3. Flight Time"); System.out.println(" 4. Number Of Seats"); System.out.println(" 5. Flight Source"); System.out.println(" 6. Flight Destination"); input = read.GetInt(); // prompt for input switch(input) // start of switch case with parameter as input { case 1: System.out.print("Please Enter the Flight Number:"); // display message to enter the flight number String tempstring1 = read.GetString(); // prompt for the flight number temp.setFlightNum(tempstring1); break; case 2: System.out.print("Please Enter the Flight Date:"); // display message to enter the flight date String tempstring2 = read.GetString(); // prompt for the flight date temp.setFlightDate(tempstring2); break; case 3: System.out.print("Please Enter the Flight Time:"); // display message to enter the flight time String tempstring3 = read.GetString(); // prompt for the flight time temp.setTime(tempstring3); break; case 4: System.out.print("Please Enter the Number of seats:"); // display message to enter the seats on flight int tempstring4 = read.GetInt(); // prompt for the seats on flight temp.setNumSeats(tempstring4); break; case 5: System.out.print("Please Enter the Source Of the Flight:"); // display message to enter the flight source
String tempstring5 = read.GetString(); // prompt for the flight source temp.setSource(tempstring5); break; case 6: System.out.print("Please Enter the Destination Of the Flight:"); // display message to enter the flight destination String tempstring6 = read.GetString(); // prompt for the flight destination temp.setDestination(tempstring6); break; default: // this is the default case which will implemented when no other condition will be true for(int j=0;j<fDetails.size();j++) // start of for loop { temp2 = (FlightDetails)fDetails.elementAt(j); if(temp2.Flight_Num.equals(flightnum)) // comparing if flight number entered got equals to flight number in the record { fDetails.insertElementAt(temp,j); } else { //do nothing } } //end of FOR -LOOP } //end of switchcase }
// main method to execute the application public static void showMenu() throws java.io.IOException { int myInput; // declaring variable do { // start of do-while loop System.out.println ("***********************************************************"); System.out.println (" || Welcome to Flight Reservation System ||"); System.out.println (" ***********************************************************"); System.out.println(" || ||"); System.out.println(" -------------- MainMenu --------------------"); System.out.println(""); System.out.println(" ------ 1. Add New Flight Details ------ "); System.out.println(" ------ 2. View Flight Details ------ "); System.out.println(" ------ 3. Save Flight Details ------ “); System.out.println(" ------ 4. Load Flight Details ------ "); System.out.println(" ------ 5. Edit Flight Details ------ "); System.out.println(" ------ 6. View Reservation Record ------ “); System.out.println(" ------ 7. Delete A Flight Record ------ “); System.out.println(" ------ 8. Exit System ------ “); System.out.println(""); System.out.println(" :::::: Enter The Number Of The Menu You Wish To Follow! :::::::"); myInput=read.GetInt(); if(myInput == 1) { AddMenu(); // call AddEntry method and add all the entries } if(myInput == 2) // if input given is 2, then { displayAll(); // call displayAll method and display all the entries } if(myInput == 3) // if input given is 3, then { saveEntry(); // call saveEntry method and save all the entries } if(myInput == 4) // if input given is 4, then { loadEntry(); // call loadEntry method and load all the entries } if(myInput == 5) // if input given is 5, then { System.out.print(" --- Please Enter Flight Number to Update: --- "); // display message to enter the flight number to update String update = read.GetString(); // prompt for flight update
updateEntry(update); // calling method updateEntry } if(myInput == 6) // if input given is 6, then { displayAllPass(); // call displayAllPass method and display all the entries } if(myInput == 7) // if input given is 7, then { delMenu(); // call delMenu method and delete the entry. } else { //do nothing } } while(myInput !=8); // if input given is 8 , then saveEntry(); // call saveEntry method and save all the entries System.out.print(" Thank you for Using The System! "); } public static void main(String args[]) throws java.io.IOException { loadEntry(); // calling method to load the entry // the lines below are just for the sake of making our code beautiful // or to give a professional touch. System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......");
System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("loading......"); System.out.println("Loading Complete"); showMenu(); // calling method showMenu }//end of Main Method }//end of class flightMenu
FlightDetails.java package frm; import java.io.*; public class FlightDetails implements Serializable { public String Flight_Num; public String FlightDate; public String Time; public int Num_Of_Seats; public String Source; public String Destination; public FlightDetails() { super(); } //constructor for the flightDetails class public FlightDetails(String fn,String fd, String t, int ns,String s,String d) { this.Flight_Num = fn; this.FlightDate = fd; this.Time = t; this.Num_Of_Seats = ns; this.Source = s; this.Destination =d; } public void setFlightNum(String flightNum) { this.Flight_Num = flightNum; } public void setFlightDate(String FDate) { this.FlightDate = FDate; } public void setTime(String time) { this.Time = time; } public void setNumSeats(int seats) { this.Num_Of_Seats = seats; } public void setSource(String SSource)
{ this.Source = SSource; } public void setDestination(String Des) { this.Destination = Des; } public void booked(int n) { this.Num_Of_Seats = this.Num_Of_Seats - n; } }//end of class
Read.java package frm; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class read { static BufferedReader In = new BufferedReader(new InputStreamReader( System.in)); public static void FlushInput() throws IOException { String str = In.readLine(); } public static char GetChar() throws IOException { char c = (char)In.read(); return c; } public static double GetDouble() throws IOException { while (true) try { String str = In.readLine().trim(); return new Double(str).doubleValue(); } catch (NumberFormatException localNumberFormatException) { } } public static float GetFloat() throws IOException { while (true) try { String str = In.readLine().trim(); return new Float(str).floatValue(); } catch (NumberFormatException localNumberFormatException) { } } public static int GetInt() throws IOException { while (true)
try { String str = In.readLine().trim(); return new Integer(str).intValue(); } catch (NumberFormatException localNumberFormatException) { } } public static long GetLong() throws IOException { while (true) try { String str = In.readLine().trim(); return new Long(str).longValue(); } catch (NumberFormatException localNumberFormatException) { } } public static String GetString() throws IOException { String str = In.readLine().trim(); return str; }
SCREENSHOTS
For System users
Add new Flight
View flight Details
Save Flight Details
Load Flight Details
Edit flight details(1)
(2)
(3)
(4)
(5)
(6)
View Flight Details
View Reservation Record
For Flight Reservation
Book Flight
Cancel Flight
Search for Flights
(2)