Faculty of Engineering, Science &
Technology
IQRA UNIVERSITY
Object Oriented
Programming
Project Report
[Summer-2023]
Name: Syed Yawer Ali
Roll no: 14592
Semester: 4th
1
Instructor Name: Ghazala Shafi Sheikh
Acknowledgment
” The best teacher teaches from the heart not from the BOOK. This report consists
of a project.”
I would like to acknowledge and all thanks to my teacher who thought me this
software and able me to use it and guide me through my project and help me so
now I am able to use the software and perform some work related to this software.
Thank you
Miss Ghazala Shafi Sheikh
2
Chapter 1 Index Pages
Objectives 2
Chapter 2
Introduction 3
Chapter 3
Description 4
Chapter 4
Coding 5
Chapter 5
Screen Shots 6
Chapter 6
Conclusion 8
3
Objectives:
The goal of the Bus Ticket Reservation System project is to create a user-friendly
application that simplifies the management of bus ticket bookings. The system
aims to offer features like adding new bus routes, viewing existing reservations,
searching for specific passenger details, and canceling reservations when needed.
By attaining these objectives, the project aims to streamline the process of bus
ticket management, reduce manual paperwork, and improve the overall efficiency
of ticket booking in the transportation industry.
Introduction:
The Student Registration System is a software project developed to digitize and
streamline the process of managing student records in educational institutions. It
replaces manual record-keeping methods with a user-friendly interface that
allows administrators to efficiently store, retrieve, and manage student
information. By implementing this system, educational institutions can improve
data accuracy, reduce paperwork, and enhance administrative efficiency.
4
Description:
• The Bus Ticket Reservation System offers a centralized hub for efficiently
handling bus ticket bookings, encompassing passenger information, route details,
and reservation status. It streamlines the process of managing reservations,
eliminating the reliance on time-consuming paperwork and manual tracking.
• Through the digital transformation of reservation records, the system
reduces the occurrence of errors, ensuring precise and reliable information. This
accuracy enhances the trustworthiness of reservation data, enabling informed
decisions based on dependable data insights.
• The Bus Ticket Reservation System facilitates enhanced communication and
cooperation among passengers, drivers, and administrators involved in the
transportation service.
5
Coding:
package yawer1;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link]. *;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class loginpage {
private Image ing_logo = new
ImageIcon(getClass().getResource("/res/[Link]")).getImage().getScaledInstanc
e(150, 98, Image.SCALE_SMOOTH);
private Image ing_log_in = new
ImageIcon(getClass().getResource("/res/[Link]")).getImage().getScaledInstanc
e(40, 40, Image.SCALE_SMOOTH);
private JFrame frame;
private JTextField textusername;
private JPasswordField textpass;
private final JLabel lblNewLabel_1 = new JLabel("X");
private JFrame homepage;
private JLabel lblLoginMessage = new JLabel("");
private JTextField txtRedBus;
/**
* Launch the application.
*/
public static void main(String[] args) {
[Link](new Runnable() {
public void run() {
try {
loginpage window = new loginpage();
[Link](true);
} catch (Exception e) {
6
[Link]();
}
}
});
}
/**
* Create the application.
*/
public loginpage() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
[Link](false);
[Link]().setBackground(new Color(220, 20, 60));
[Link](100, 100, 729, 406);
[Link](JFrame.EXIT_ON_CLOSE);
[Link]().setLayout(null);
[Link](true);
JPanel panel = new JPanel();
[Link](new EmptyBorder(0, 0, 0, 0));
[Link](new Color(255, 255, 255));
[Link](247, 170, 216, 43);
[Link]().add(panel);
[Link](null);
textusername = new JTextField();
[Link](new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
if ([Link]().equals("Username")) {
[Link]("");
} else {
[Link]();
}
}
@Override
public void focusLost(FocusEvent e) {
if ([Link]().equals("")) {
[Link]("Username");
}
}}
);
[Link](null);
7
[Link](new Font("Arial", [Link], 12));
[Link]("Username");
[Link](10, 11, 146, 21);
[Link](textusername);
[Link](10);
JPanel panel_1 = new JPanel();
panel_1.setBorder(new EmptyBorder(0, 0, 0, 0));
panel_1.setLayout(null);
panel_1.setBackground([Link]);
panel_1.setBounds(247, 224, 216, 43);
[Link]().add(panel_1);
textpass = new JPasswordField();
[Link](new Font("Arial", [Link], 12));
[Link](new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
if ([Link]().equals("Password")) {
[Link]('●'); // Use single quotes for
char literal
[Link]("");
} else {
[Link]();
}
} @Override
public void focusLost(FocusEvent e) {
if ([Link]().equals("")) {
[Link]("Password");
[Link]((char)0);
}
}}
);
[Link](null);
[Link]((char)0);
[Link]("Password");
[Link](10, 11, 147, 21);
panel_1.add(textpass);
JPanel Loginbutton = new JPanel();
[Link](new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if ([Link]().equals("yawer") &&
[Link]().equals("yawer123")) {
[Link]("");
[Link]( null,"Successful
Login");
[Link]();
homepage home = new homepage();
[Link](true);
}
8
else if ([Link]().equals("") &&
[Link]().equals("")) {
[Link]("Please input fields
first!");
}
else if ([Link]().equals("") ||
[Link]().equals("username") ||
[Link]().equals("") ||
[Link]().equals("password")) {
[Link]("Please input all
requirements!");
else {
[Link]("Username and Password didn't
match!");
}
} @Override
public void mouseEntered(MouseEvent e) {
[Link]([Link]);
}
@Override
public void mouseExited(MouseEvent e) {
[Link](Color.DARK_GRAY);
}
}
);
[Link](Color.DARK_GRAY);
[Link](247, 300, 216, 43);
[Link]().add(Loginbutton);
[Link](null);
JLabel lblNewLabel = new JLabel("LOG IN");
[Link]([Link]);
[Link](new Font("Arial", [Link], 12));
[Link](107, 11, 99, 21);
[Link](lblNewLabel);
JLabel lblNewLabel_2 = new JLabel("");
lblNewLabel_2.setHorizontalAlignment([Link]);
lblNewLabel_2.setBounds(59, 0, 46, 53);
lblNewLabel_2.setIcon(new ImageIcon(ing_log_in));
[Link](lblNewLabel_2);
JLabel lblNewIcon_1 = new JLabel("");
lblNewIcon_1.setHorizontalAlignment([Link]);
lblNewIcon_1.setBounds(247, 47, 216, 122);
lblNewIcon_1.setIcon(new ImageIcon(ing_logo));
9
[Link]().add(lblNewIcon_1);
lblNewLabel_1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if ([Link](null, "Are you sure
you want to close this application?", "Confirmation",
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
[Link](0); // Close the application
}
}
@Override
public void mouseEntered(MouseEvent e) {
lblNewLabel_1.setForeground([Link]);
}
@Override
public void mouseExited(MouseEvent e) {
lblNewLabel_1.setForeground([Link]);
}
});
lblNewLabel_1.setFont(new Font("Tahoma", [Link], 11));
lblNewLabel_1.setBorder(null);
lblNewLabel_1.setForeground(new Color(255, 255, 255));
lblNewLabel_1.setHorizontalAlignment([Link]);
lblNewLabel_1.setBounds(685, 0, 44, 43);
[Link]().add(lblNewLabel_1);
[Link]([Link]);
[Link](new Color(0, 0, 0));
[Link](new Font("Arial", [Link], 11));
[Link](247, 278, 216, 14);
[Link]().add(lblLoginMessage);
txtRedBus = new JTextField();
[Link](null);
[Link](false);
[Link](new Font("Arial", [Link], 18));
[Link]([Link]);
[Link](new Color(128, 0, 0));
[Link]("RED BUS");
[Link](247, 30, 217, 33);
[Link]().add(txtRedBus);
[Link](10);
}
}
CODING FOR HOME PAGE
package yawer1;
import [Link];
10
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class homepage extends JFrame {
private Image ing_logo = new
ImageIcon(getClass().getResource("/res/[Link]")).getImage().getScaledInstanc
e(150, 98, Image.SCALE_SMOOTH);
private JPanel contentPane;
private JTextField txtTax;
private JTextField txtSub;
private JTextField txtTotal;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_3;
private JTextField textField_4;
private JTextField textFieldDate;
private JTextField textField_7;
private JTextField textField_8;
private JTextField textField_9;
/**
* Launch the application.
*/
public static void main(String[] args) {
[Link](new Runnable() {
public void run() {
try {
homepage frame = new homepage();
[Link](true);
11
} catch (Exception e) {
[Link]();
}
}
});
}
/**
* Create the frame.
*/
public homepage() {
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(0, 0, 1200, 700);
contentPane = new JPanel();
[Link](new Color(220, 20, 60));
[Link](new EmptyBorder(5, 5, 5, 5));
setUndecorated(true);
setContentPane(contentPane);
[Link](null);
JPanel panel = new JPanel();
[Link](new Color(0, 0, 0));
[Link](null);
[Link](10, 10, 1180, 85);
[Link](panel);
JLabel lblNewLabel = new JLabel("BUS TICKETING SYSTEM");
[Link]([Link]);
[Link](new Color(220, 20, 60));
[Link](new Font("Arial", [Link], 26));
[Link](lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("");
lblNewLabel_1.setForeground(new Color(255, 255, 255));
[Link](lblNewLabel_1);
JLabel label = new JLabel("");
[Link](label);
[Link](200, 47, 216, 122);
[Link](new ImageIcon(ing_logo));
JLabel lblNewLabel_2 = new JLabel("Ticket type");
lblNewLabel_2.setForeground(new Color(0, 0, 0));
lblNewLabel_2.setHorizontalAlignment([Link]);
lblNewLabel_2.setFont(new Font("Arial", [Link], 26));
lblNewLabel_2.setBounds(55, 125, 317, 27);
[Link](lblNewLabel_2);
JRadioButton rdbtnAC = new JRadioButton("With AC");
[Link](null);
[Link](new Color(220, 20, 60));
[Link](new Font("Arial", [Link], 18));
12
[Link](new Color(0, 0, 0));
[Link](55, 190, 103, 21);
[Link](rdbtnAC);
JRadioButton rdbtnNOAC = new JRadioButton("Without AC");
[Link](null);
[Link](new Color(220, 20, 60));
[Link](new Font("Arial", [Link], 18));
[Link](55, 231, 135, 21);
[Link](rdbtnNOAC);
JRadioButton rdbtnAdult = new JRadioButton("Adult");
[Link](new Color(220, 20, 60));
[Link](new Font("Arial", [Link], 18));
[Link](null);
[Link](254, 190, 103, 21);
[Link](rdbtnAdult);
JRadioButton rdbtnChild = new JRadioButton("Child");
[Link](new Font("Arial", [Link], 18));
[Link](new Color(220, 20, 60));
[Link](254, 231, 103, 21);
[Link](rdbtnChild);
JComboBox comboBox = new JComboBox();
[Link](new Font("Arial", [Link], 18));
[Link](new DefaultComboBoxModel(new String[]
{"Destination", "Shahra-e-Faisal", "Tower", "Saddar", "Zainab Maket ", "2
Talwar"}));
[Link](55, 289, 317, 34);
[Link](comboBox);
JSeparator separator = new JSeparator();
[Link](65, 162, 307, 2);
[Link](separator);
JSeparator separator_1 = new JSeparator();
separator_1.setBounds(55, 344, 317, 2);
[Link](separator_1);
JLabel lblNewLabel_3 = new JLabel("Tax");
lblNewLabel_3.setFont(new Font("Arial", [Link], 18));
lblNewLabel_3.setBounds(87, 388, 85, 21);
[Link](lblNewLabel_3);
JLabel lblNewLabel_4 = new JLabel("Subtotal");
lblNewLabel_4.setFont(new Font("Arial", [Link], 18));
lblNewLabel_4.setBounds(87, 435, 103, 27);
[Link](lblNewLabel_4);
JLabel lblNewLabel_5 = new JLabel("Total");
lblNewLabel_5.setFont(new Font("Arial", [Link], 18));
lblNewLabel_5.setBounds(87, 494, 85, 27);
[Link](lblNewLabel_5);
13
txtTax = new JTextField();
[Link]([Link]);
[Link](null);
[Link](254, 383, 111, 36);
[Link](txtTax);
[Link](10);
txtSub = new JTextField();
[Link]([Link]);
[Link](null);
[Link](254, 431, 111, 39);
[Link](txtSub);
[Link](10);
txtTotal = new JTextField();
[Link]([Link]);
[Link](null);
[Link](254, 493, 111, 34);
[Link](txtTotal);
[Link](10);
JButton btnNewButton = new JButton("TOTAL");
[Link](new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
double tax = 19.50;
double MilesK8 = 25.78;
double MilesK12 = 25.10;
double MilesK20 = 45.23;
double MilesK30 = 55.98;
double totalCost, eco = 3.85, fclass = 5.60;
if ( [Link]() && [Link]()
&& [Link]().equals("Tower")) {
totalCost = (tax * MilesK8) / 100;
String sTax = [Link]("£%.2f", totalCost);
[Link](sTax);
String subTotal = [Link]("£%.2f",
MilesK8);
[Link](subTotal);
double totalWithTax = MilesK8 + totalCost;
String Total = [Link]("£%.2f",
totalWithTax);
[Link](Total);
textField_8.setText(Total);
[Link]("AC");
textField_1.setText("ONE");
textField_2.setText("NIL");
}
14
else if
( [Link]() && [Link]() &&
[Link]().equals("Shahra-e-Faisal")) {
totalCost = (tax * MilesK8) / 100;
String sTax = [Link]("£%.2f", totalCost);
[Link](sTax);
String subTotal = [Link]("£%.2f",
MilesK8);
[Link](subTotal);
double totalWithTax = MilesK8 + totalCost;
String Total = [Link]("£%.2f",
totalWithTax);
[Link](Total);
textField_8.setText(Total);
[Link]("AC");
textField_1.setText("ONE");
textField_2.setText("NIL");
}else if
( [Link]() && [Link]() &&
[Link]().equals("Saddar")) {
totalCost = (tax * MilesK8) / 100;
String sTax = [Link]("£%.2f", totalCost);
[Link](sTax);
String subTotal = [Link]("£%.2f", MilesK8);
[Link](subTotal);
double totalWithTax = MilesK8 + totalCost;
String Total = [Link]("£%.2f", totalWithTax);
[Link](Total);
textField_8.setText(Total);
[Link]("AC");
textField_1.setText("ONE");
textField_2.setText("NIL");
}
else if
( [Link]() && [Link]() &&
[Link]().equals("Zainab Maket ")) {
totalCost = (tax * MilesK8) / 100;
String sTax = [Link]("£%.2f", totalCost);
[Link](sTax);
15
String subTotal = [Link]("£%.2f",
MilesK8);
[Link](subTotal);
double totalWithTax = MilesK8 + totalCost;
String Total = [Link]("£%.2f",
totalWithTax);
[Link](Total);
textField_8.setText(Total);
[Link]("AC");
textField_1.setText("ONE");
textField_2.setText("NIL");
}
else if
( [Link]() && [Link]() &&
[Link]().equals("2 Talwar")) {
totalCost = (tax * MilesK8) / 100;
String sTax = [Link]("£%.2f", totalCost);
[Link](sTax);
String subTotal = [Link]("£%.2f",
MilesK8);
[Link](subTotal);
double totalWithTax = MilesK8 + totalCost;
String Total = [Link]("£%.2f",
totalWithTax);
[Link](Total);
textField_8.setText(Total);
[Link]("AC");
textField_1.setText("ONE");
textField_2.setText("NIL");
}
});
[Link](new ActionListener() {
public void actionPerformed(ActionEvent e) {
Calendar timer = [Link]();
[Link]();
SimpleDateFormat tTime = new
SimpleDateFormat("HH:mm:ss");
textField_7.setText([Link]([Link]()));
16
SimpleDateFormat Tdate= new SimpleDateFormat("dd-MMM-
yyyy");
[Link]([Link]([Link]()));
textField_3.setText("London *");
textField_4.setText((String)
[Link]() + " *");
int num1;
String q1="";
num1 = 1325 + (int) ([Link]()*4238);
q1 += num1 + 1325;
textField_7.setText(q1);
textField_9.setText("ANY");
}
});
[Link]("TOTAL COST");
[Link](new Font("Tahoma", [Link], 14));
[Link](65, 589, 85, 21);
[Link](btnNewButton);
JButton btnNewButton_1 = new JButton("RESET");
btnNewButton_1.setToolTipText("RESET SYSTEM");
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
[Link](null);
[Link](null);
[Link](null);
[Link](false);
[Link](false);
[Link](false);
[Link](false);
[Link]("Destination");
[Link](null);
textField_1.setText(null);
textField_2.setText(null);
textField_3.setText(null);
textField_4.setText(null);
[Link](null);
textField_7.setText(null);
textField_8.setText(null);
textField_9.setText(null);
}
});
btnNewButton_1.setFont(new Font("Tahoma", [Link], 14));
17
btnNewButton_1.setBounds(176, 589, 85, 21);
[Link](btnNewButton_1);
JButton btnNewButton_2 = new JButton("EXIT");
btnNewButton_2.setToolTipText("EXIT SYSTEM");
btnNewButton_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if ([Link](null, "do you want
to exit?", "Confirmation", JOptionPane.YES_NO_OPTION) ==
JOptionPane.YES_OPTION) {
[Link](0); // Close the application
}
}
});
btnNewButton_2.setFont(new Font("Tahoma", [Link], 14));
btnNewButton_2.setBounds(287, 589, 85, 21);
[Link](btnNewButton_2);
JSeparator separator_2 = new JSeparator();
separator_2.setBounds(55, 552, 317, 2);
[Link](separator_2);
JSeparator separator_3 = new JSeparator();
separator_3.setOrientation([Link]);
separator_3.setBounds(409, 140, 2, 485);
[Link](separator_3);
JLabel lblNewLabelTYPE = new JLabel("Type");
[Link]([Link]);
[Link]([Link]);
[Link](new Font("Arial", [Link], 26));
[Link](474, 125, 187, 27);
[Link](lblNewLabelTYPE);
JLabel lblNewLabelADULT = new JLabel("Adult");
[Link]([Link]);
[Link]([Link]);
[Link](new Font("Arial", [Link], 26));
[Link](705, 125, 187, 27);
[Link](lblNewLabelADULT);
JLabel lblNewLabelCHILD = new JLabel("Child");
[Link]([Link]);
[Link]([Link]);
[Link](new Font("Arial", [Link], 26));
[Link](940, 125, 187, 27);
[Link](lblNewLabelCHILD);
JSeparator separator_4 = new JSeparator();
separator_4.setBounds(449, 162, 709, 2);
[Link](separator_4);
textField = new JTextField();
[Link]([Link]);
18
[Link](10);
[Link](null);
[Link](514, 204, 111, 36);
[Link](textField);
textField_1 = new JTextField();
textField_1.setHorizontalAlignment([Link]);
textField_1.setColumns(10);
textField_1.setBorder(null);
textField_1.setBounds(750, 204, 111, 36);
[Link](textField_1);
textField_2 = new JTextField();
textField_2.setHorizontalAlignment([Link]);
textField_2.setColumns(10);
textField_2.setBorder(null);
textField_2.setBounds(982, 204, 111, 36);
[Link](textField_2);
JSeparator separator_5 = new JSeparator();
separator_5.setBounds(449, 268, 709, 2);
[Link](separator_5);
JSeparator separator_6 = new JSeparator();
separator_6.setOrientation([Link]);
separator_6.setBounds(799, 310, 2, 313);
[Link](separator_6);
JLabel lblTo = new JLabel("To");
[Link]([Link]);
[Link]([Link]);
[Link](new Font("Arial", [Link], 26));
[Link](434, 455, 126, 27);
[Link](lblTo);
JLabel lblFrom = new JLabel("From");
[Link]([Link]);
[Link]([Link]);
[Link](new Font("Arial", [Link], 26));
[Link](440, 364, 143, 27);
[Link](lblFrom);
JLabel lblDate = new JLabel("Date");
[Link]([Link]);
[Link]([Link]);
[Link](new Font("Arial", [Link], 26));
[Link](440, 546, 135, 27);
[Link](lblDate);
JLabel lblTicketNo = new JLabel("Ticket No");
[Link]([Link]);
[Link]([Link]);
[Link](new Font("Arial", [Link], 26));
[Link](830, 354, 187, 27);
19
[Link](lblTicketNo);
JLabel lblPrice = new JLabel("Price");
[Link]([Link]);
[Link]([Link]);
[Link](new Font("Arial", [Link], 26));
[Link](808, 443, 187, 27);
[Link](lblPrice);
JLabel lblRoute = new JLabel("Route");
[Link]([Link]);
[Link]([Link]);
[Link](new Font("Arial", [Link], 26));
[Link](811, 536, 187, 27);
[Link](lblRoute);
textField_3 = new JTextField();
textField_3.setHorizontalAlignment([Link]);
textField_3.setColumns(10);
textField_3.setBorder(null);
textField_3.setBounds(607, 355, 111, 36);
[Link](textField_3);
textField_4 = new JTextField();
textField_4.setHorizontalAlignment([Link]);
textField_4.setColumns(10);
textField_4.setBorder(null);
textField_4.setBounds(607, 446, 111, 36);
[Link](textField_4);
textFieldDate = new JTextField();
[Link]([Link]);
[Link](10);
[Link](null);
[Link](607, 537, 111, 36);
[Link](textFieldDate);
textField_7 = new JTextField();
textField_7.setHorizontalAlignment([Link]);
textField_7.setColumns(10);
textField_7.setBorder(null);
textField_7.setBounds(906, 393, 111, 36);
[Link](textField_7);
textField_8 = new JTextField();
textField_8.setHorizontalAlignment([Link]);
textField_8.setColumns(10);
textField_8.setBorder(null);
textField_8.setBounds(906, 482, 111, 36);
[Link](textField_8);
textField_9 = new JTextField();
textField_9.setHorizontalAlignment([Link]);
textField_9.setColumns(10);
20
textField_9.setBorder(null);
textField_9.setBounds(906, 566, 111, 36);
[Link](textField_9);
Screen Shots:
21
22
23
24
Conclusion:
In conclusion, the Bus Ticket Reservation System stands as a valuable solution
that revolutionizes the management of bus ticket bookings and optimizes the
efficiency of the transportation service. By consolidating reservation details, the
system offers a simplified and error-resistant avenue for reservation
management, guaranteeing precise data handling and dependability. On the
whole, the Bus Ticket Reservation System serves as an indispensable tool for
transportation companies, presenting a range of advantages in terms of data
administration, operational effectiveness, and passenger contentment.
25