diff --git a/Comp Crew/BookBus.java b/Comp Crew/BookBus.java new file mode 100644 index 0000000..f73b061 --- /dev/null +++ b/Comp Crew/BookBus.java @@ -0,0 +1,707 @@ +package pkg1; +//package winBuilder; + +import java.util.*; +import java.awt.Color; +import java.awt.Font; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JButton; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.SystemColor; + +public class BookBus +{ + static JLabel selected; + static JLabel message; + static JLabel ticketnum; + static JLabel totalprice; + static JLabel noselection; + int ct=0; + //queue containing booked seats + static Queue q = new LinkedList(); + static Queue tempq = new LinkedList(); + + static JFrame frame; + BookBus(String from,String to,String date,String res,int key,double price) + { + frame = new JFrame(); + frame.getContentPane().setBackground(new Color(240, 240, 240)); + frame.getContentPane().setFont(new Font("Tahoma", Font.PLAIN, 14)); + frame.getContentPane().setLayout(null); + + JLabel available = new JLabel("Available Seats :"); + available.setFont(new Font("Times New Roman", Font.BOLD, 14)); + available.setBounds(31, 23, 292, 26); + frame.getContentPane().add(available); + + JButton b11 = new JButton("11"); + b11.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) + { + if(!q.contains(b11)) + { + message.setText("Seat 11 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 11"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b11).setBackground(Color.BLUE); + q.add(b11); + tempq.add(b11); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b11.setBackground(new Color(50, 205, 50)); + b11.setFont(new Font("Tahoma", Font.BOLD, 9)); + b11.setBounds(172, 34, 43, 43); + frame.getContentPane().add(b11); + + JButton b12 = new JButton("12"); + b12.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b12)) + { + message.setText("Seat 12 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 12"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b12).setBackground(Color.BLUE); + q.add(b12); + tempq.add(b12); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b12.setBackground(new Color(50, 205, 50)); + b12.setFont(new Font("Tahoma", Font.BOLD, 9)); + b12.setBounds(225, 34, 43, 43); + frame.getContentPane().add(b12); + + JButton b13 = new JButton("13"); + b13.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b13)) + { + message.setText("Seat 13 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 13"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b13).setBackground(Color.BLUE); + q.add(b13); + tempq.add(b13); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b13.setBackground(new Color(50, 205, 50)); + b13.setFont(new Font("Tahoma", Font.BOLD, 9)); + b13.setBounds(278, 34, 43, 43); + frame.getContentPane().add(b13); + + JButton b14 = new JButton("14"); + b14.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b14)) + { + message.setText("Seat 14 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 14"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b14).setBackground(Color.BLUE); + q.add(b14); + tempq.add(b14); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b14.setBackground(new Color(50, 205, 50)); + b14.setFont(new Font("Tahoma", Font.BOLD, 9)); + b14.setBounds(333, 34, 43, 43); + frame.getContentPane().add(b14); + + JButton b21 = new JButton("21"); + b21.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b21)) + { + message.setText("Seat 21 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 21"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b21).setBackground(Color.BLUE); + q.add(b21); + tempq.add(b21); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b21.setBackground(new Color(50, 205, 50)); + b21.setFont(new Font("Tahoma", Font.BOLD, 9)); + b21.setBounds(172, 87, 43, 43); + frame.getContentPane().add(b21); + + JButton b22 = new JButton("22"); + b22.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b22)) + { + message.setText("Seat 22 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 22"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b22).setBackground(Color.BLUE); + q.add(b22); + tempq.add(b22); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b22.setBackground(new Color(50, 205, 50)); + b22.setFont(new Font("Tahoma", Font.BOLD, 9)); + b22.setBounds(225, 87, 43, 43); + frame.getContentPane().add(b22); + + JButton b23 = new JButton("23"); + b23.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + message.setText("Already Booked."); + } + }); + b23.setBackground(new Color(255, 0, 0)); + b23.setFont(new Font("Tahoma", Font.BOLD, 9)); + b23.setBounds(280, 87, 43, 43); + frame.getContentPane().add(b23); + + JButton b24 = new JButton("24"); + b24.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b22)) + { + message.setText("Seat 24 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 24"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b24).setBackground(Color.BLUE); + q.add(b24); + tempq.add(b24); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b24.setBackground(new Color(50, 205, 50)); + b24.setFont(new Font("Tahoma", Font.BOLD, 9)); + b24.setBounds(333, 87, 43, 43); + frame.getContentPane().add(b24); + + JButton b34 = new JButton("34"); + b34.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b34)) + { + message.setText("Seat 34 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 34"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b34).setBackground(Color.BLUE); + q.add(b34); + tempq.add(b34); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b34.setBackground(new Color(50, 205, 50)); + b34.setFont(new Font("Tahoma", Font.BOLD, 9)); + b34.setBounds(333, 140, 43, 43); + frame.getContentPane().add(b34); + + JButton b33 = new JButton("33"); + b33.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b33)) + { + message.setText("Seat 33 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 33"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b33).setBackground(Color.BLUE); + q.add(b33); + tempq.add(b33); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b33.setBackground(new Color(50, 205, 50)); + b33.setFont(new Font("Tahoma", Font.BOLD, 9)); + b33.setBounds(278, 140, 43, 43); + frame.getContentPane().add(b33); + + JButton b32 = new JButton("32"); + b32.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b32)) + { + message.setText("Seat 32 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 32"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b32).setBackground(Color.BLUE); + q.add(b32); + tempq.add(b32); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b32.setBackground(new Color(50, 205, 50)); + b32.setFont(new Font("Tahoma", Font.BOLD, 9)); + b32.setBounds(225, 140, 43, 43); + frame.getContentPane().add(b32); + + JButton b31 = new JButton("31"); + b31.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b31)) + { + message.setText("Seat 31 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 31"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b31).setBackground(Color.BLUE); + q.add(b31); + tempq.add(b31); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b31.setBackground(new Color(50, 205, 50)); + b31.setFont(new Font("Tahoma", Font.BOLD, 9)); + b31.setBounds(172, 140, 43, 43); + frame.getContentPane().add(b31); + + JButton b44 = new JButton("44"); + b44.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b44)) + { + message.setText("Seat 44 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 44"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b44).setBackground(Color.BLUE); + q.add(b44); + tempq.add(b44); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b44.setBackground(new Color(50, 205, 50)); + b44.setFont(new Font("Tahoma", Font.BOLD, 9)); + b44.setBounds(333, 193, 43, 43); + frame.getContentPane().add(b44); + + JButton b43 = new JButton("43"); + b43.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b43)) + { + message.setText("Seat 43 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 43"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b43).setBackground(Color.BLUE); + q.add(b43); + tempq.add(b43); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b43.setBackground(new Color(50, 205, 50)); + b43.setFont(new Font("Tahoma", Font.BOLD, 9)); + b43.setBounds(278, 193, 43, 43); + frame.getContentPane().add(b43); + + JButton b42 = new JButton("42"); + b42.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b42)) + { + message.setText("Seat 42 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 42"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b42).setBackground(Color.BLUE); + q.add(b42); + tempq.add(b42); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b42.setBackground(new Color(50, 205, 50)); + b42.setFont(new Font("Tahoma", Font.BOLD, 9)); + b42.setBounds(225, 193, 43, 43); + frame.getContentPane().add(b42); + + JButton b41 = new JButton("41"); + b41.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + message.setText("Already Booked."); + } + }); + b41.setBackground(new Color(255, 0, 0)); + b41.setFont(new Font("Tahoma", Font.BOLD, 9)); + b41.setBounds(172, 193, 43, 43); + frame.getContentPane().add(b41); + + JButton b51 = new JButton("51"); + b51.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b51)) + { + message.setText("Seat 51 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 51"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b51).setBackground(Color.BLUE); + q.add(b51); + tempq.add(b51); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b51.setBackground(new Color(50, 205, 50)); + b51.setFont(new Font("Tahoma", Font.BOLD, 9)); + b51.setBounds(172, 246, 43, 43); + frame.getContentPane().add(b51); + + JButton b52 = new JButton("52"); + b52.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b52)) + { + message.setText("Seat 52 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 52"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b52).setBackground(Color.BLUE); + q.add(b52); + tempq.add(b52); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b52.setBackground(new Color(50, 205, 50)); + b52.setFont(new Font("Tahoma", Font.BOLD, 9)); + b52.setBounds(225, 246, 43, 43); + frame.getContentPane().add(b52); + + JButton b53 = new JButton("53"); + b53.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + message.setText("Already Booked."); + } + }); + b53.setBackground(new Color(255, 0, 0)); + b53.setFont(new Font("Tahoma", Font.BOLD, 9)); + b53.setBounds(280, 246, 43, 43); + frame.getContentPane().add(b53); + + JButton b54 = new JButton("54"); + b54.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b54)) + { + message.setText("Seat 54 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 54"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b54).setBackground(Color.BLUE); + q.add(b54); + tempq.add(b54); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b54.setBackground(new Color(50, 205, 50)); + b54.setFont(new Font("Tahoma", Font.BOLD, 9)); + b54.setBounds(333, 246, 43, 43); + frame.getContentPane().add(b54); + + JButton b64 = new JButton("64"); + b64.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b64)) + { + message.setText("Seat 64 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 64"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b64).setBackground(Color.BLUE); + q.add(b64); + tempq.add(b64); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b64.setBackground(new Color(50, 205, 50)); + b64.setFont(new Font("Tahoma", Font.BOLD, 9)); + b64.setBounds(333, 299, 43, 43); + frame.getContentPane().add(b64); + + JButton b63 = new JButton("63"); + b63.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b63)) + { + message.setText("Seat 63 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 63"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b63).setBackground(Color.BLUE); + q.add(b63); + tempq.add(b63); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b63.setBackground(new Color(50, 205, 50)); + b63.setFont(new Font("Tahoma", Font.BOLD, 9)); + b63.setBounds(278, 299, 43, 43); + frame.getContentPane().add(b63); + + JButton b62 = new JButton("62"); + b62.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b62)) + { + message.setText("Seat 62 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 62"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b62).setBackground(Color.BLUE); + q.add(b62); + tempq.add(b62); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b62.setBackground(new Color(50, 205, 50)); + b62.setFont(new Font("Tahoma", Font.BOLD, 9)); + b62.setBounds(225, 299, 43, 43); + frame.getContentPane().add(b62); + + JButton b61 = new JButton("61"); + b61.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b61)) + { + message.setText("Seat 61 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 61"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b61).setBackground(Color.BLUE); + q.add(b61); + tempq.add(b61); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b61.setBackground(new Color(50, 205, 50)); + b61.setFont(new Font("Tahoma", Font.BOLD, 9)); + b61.setBounds(172, 299, 43, 43); + frame.getContentPane().add(b61); + + JLabel labelx = new JLabel("Selected Seats :"); + labelx.setFont(new Font("Times New Roman", Font.BOLD, 14)); + labelx.setBounds(31, 375, 106, 26); + frame.getContentPane().add(labelx); + + selected = new JLabel(""); + selected.setFont(new Font("Times New Roman", Font.BOLD, 14)); + selected.setBounds(147, 384, 292, 17); + frame.getContentPane().add(selected); + + message = new JLabel(""); + message.setFont(new Font("Times New Roman", Font.PLAIN, 12)); + message.setBounds(172, 352, 202, 17); + frame.getContentPane().add(message); + + JLabel lblNewLabel = new JLabel("No of Tickets: "); + lblNewLabel.setFont(new Font("Times New Roman", Font.BOLD, 14)); + lblNewLabel.setBounds(31, 412, 106, 13); + frame.getContentPane().add(lblNewLabel); + + ticketnum = new JLabel(""); + ticketnum.setFont(new Font("Tahoma", Font.PLAIN, 14)); + ticketnum.setBounds(147, 411, 57, 17); + frame.getContentPane().add(ticketnum); + + JLabel lblNewLabel_1 = new JLabel("Total Price:"); + lblNewLabel_1.setFont(new Font("Times New Roman", Font.BOLD, 14)); + lblNewLabel_1.setBounds(31, 447, 86, 13); + frame.getContentPane().add(lblNewLabel_1); + + totalprice = new JLabel(""); + totalprice.setFont(new Font("Tahoma", Font.PLAIN, 14)); + totalprice.setBounds(147, 441, 68, 19); + frame.getContentPane().add(totalprice); + + JButton pay = new JButton("Confirm and Pay"); + pay.setBackground(SystemColor.activeCaption); + pay.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) + { + if(price!=ct) + { + while(!tempq.isEmpty()) + { + (tempq.poll()).setBackground(Color.RED); + } + + new DisplayTicket(from,to,date,res,key,ct,price,selected.getText()); + } + else + noselection.setText("Please Select Seats...!"); + } + }); + pay.setBounds(31, 470, 202, 26); + frame.getContentPane().add(pay); + + noselection = new JLabel(""); + noselection.setFont(new Font("Tahoma", Font.PLAIN, 14)); + noselection.setForeground(new Color(255, 0, 0)); + noselection.setBounds(31, 506, 304, 17); + frame.getContentPane().add(noselection); + + frame.setSize(463,585); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + } +} \ No newline at end of file diff --git a/Comp Crew/BookRailway.java b/Comp Crew/BookRailway.java new file mode 100644 index 0000000..ce85592 --- /dev/null +++ b/Comp Crew/BookRailway.java @@ -0,0 +1,731 @@ +package pkg1; +//package winBuilder; + +import java.awt.Color; +import java.awt.Font; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JButton; +import java.awt.event.ActionListener; +import java.util.LinkedList; +import java.util.Queue; +import java.awt.event.ActionEvent; +import java.awt.SystemColor; + +public class BookRailway +{ + static JLabel selected; + static JLabel message; + static JLabel ticketnum; + static JLabel totalprice; + static JLabel noselection; + int ct=0; + static Queue q = new LinkedList(); + static Queue tempq = new LinkedList(); + + static JFrame frame; + BookRailway(String from,String to,String date,String res,int key,double price) + { + frame = new JFrame(); + frame.getContentPane().setBackground(new Color(240, 240, 240)); + frame.getContentPane().setFont(new Font("Tahoma", Font.PLAIN, 14)); + frame.getContentPane().setLayout(null); + + JLabel available = new JLabel("Available Seats :"); + available.setFont(new Font("Times New Roman", Font.BOLD, 14)); + available.setBounds(31, 23, 292, 26); + frame.getContentPane().add(available); + + JButton b11 = new JButton("11"); + b11.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) + { + if(!q.contains(b11)) + { + message.setText("Seat 11 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 11"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b11).setBackground(Color.BLUE); + q.add(b11); + tempq.add(b11); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b11.setBackground(new Color(50, 205, 50)); + b11.setFont(new Font("Tahoma", Font.BOLD, 9)); + b11.setBounds(172, 34, 43, 43); + frame.getContentPane().add(b11); + + JButton b12 = new JButton("12"); + b12.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b12)) + { + message.setText("Seat 12 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 12"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b12).setBackground(Color.BLUE); + q.add(b12); + tempq.add(b12); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b12.setBackground(new Color(50, 205, 50)); + b12.setFont(new Font("Tahoma", Font.BOLD, 9)); + b12.setBounds(225, 34, 43, 43); + frame.getContentPane().add(b12); + + JButton b13 = new JButton("13"); + b13.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b13)) + { + message.setText("Seat 13 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 13"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b13).setBackground(Color.BLUE); + q.add(b13); + tempq.add(b13); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b13.setBackground(new Color(50, 205, 50)); + b13.setFont(new Font("Tahoma", Font.BOLD, 9)); + b13.setBounds(172, 87, 43, 43); + frame.getContentPane().add(b13); + + JButton b14 = new JButton("14"); + b14.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b14)) + { + message.setText("Seat 14 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 14"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b14).setBackground(Color.BLUE); + q.add(b14); + tempq.add(b14); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b14.setBackground(new Color(50, 205, 50)); + b14.setFont(new Font("Tahoma", Font.BOLD, 9)); + b14.setBounds(225, 87, 43, 43); + frame.getContentPane().add(b14); + + JButton b21 = new JButton("21"); + b21.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b21)) + { + message.setText("Seat 21 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 21"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b21).setBackground(Color.BLUE); + q.add(b21); + tempq.add(b21); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b21.setBackground(new Color(50, 205, 50)); + b21.setFont(new Font("Tahoma", Font.BOLD, 9)); + b21.setBounds(172, 140, 43, 43); + frame.getContentPane().add(b21); + + JButton b22 = new JButton("22"); + b22.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b22)) + { + message.setText("Seat 22 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 22"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b22).setBackground(Color.BLUE); + q.add(b22); + tempq.add(b22); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b22.setBackground(new Color(50, 205, 50)); + b22.setFont(new Font("Tahoma", Font.BOLD, 9)); + b22.setBounds(225, 140, 43, 43); + frame.getContentPane().add(b22); + + JButton b23 = new JButton("23"); + b23.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + message.setText("Already Booked."); + } + }); + b23.setBackground(new Color(255, 0, 0)); + b23.setFont(new Font("Tahoma", Font.BOLD, 9)); + b23.setBounds(172, 193, 43, 43); + frame.getContentPane().add(b23); + + JButton b24 = new JButton("24"); + b24.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b22)) + { + message.setText("Seat 24 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 24"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b24).setBackground(Color.BLUE); + q.add(b24); + tempq.add(b24); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b24.setBackground(new Color(50, 205, 50)); + b24.setFont(new Font("Tahoma", Font.BOLD, 9)); + b24.setBounds(225, 193, 43, 43); + frame.getContentPane().add(b24); + + JButton b34 = new JButton("34"); + b34.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b34)) + { + message.setText("Seat 34 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 34"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b34).setBackground(Color.BLUE); + q.add(b34); + tempq.add(b34); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b34.setBackground(new Color(50, 205, 50)); + b34.setFont(new Font("Tahoma", Font.BOLD, 9)); + b34.setBounds(386, 87, 43, 43); + frame.getContentPane().add(b34); + + JButton b33 = new JButton("33"); + b33.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b33)) + { + message.setText("Seat 33 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 33"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b33).setBackground(Color.BLUE); + q.add(b33); + tempq.add(b33); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b33.setBackground(new Color(50, 205, 50)); + b33.setFont(new Font("Tahoma", Font.BOLD, 9)); + b33.setBounds(333, 87, 43, 43); + frame.getContentPane().add(b33); + + JButton b32 = new JButton("32"); + b32.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b32)) + { + message.setText("Seat 32 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 32"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b32).setBackground(Color.BLUE); + q.add(b32); + tempq.add(b32); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b32.setBackground(new Color(50, 205, 50)); + b32.setFont(new Font("Tahoma", Font.BOLD, 9)); + b32.setBounds(388, 34, 43, 43); + frame.getContentPane().add(b32); + + JButton b31 = new JButton("31"); + b31.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b31)) + { + message.setText("Seat 31 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 31"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b31).setBackground(Color.BLUE); + q.add(b31); + tempq.add(b31); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b31.setBackground(new Color(50, 205, 50)); + b31.setFont(new Font("Tahoma", Font.BOLD, 9)); + b31.setBounds(333, 34, 43, 43); + frame.getContentPane().add(b31); + + JButton b44 = new JButton("44"); + b44.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b44)) + { + message.setText("Seat 44 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 44"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b44).setBackground(Color.BLUE); + q.add(b44); + tempq.add(b44); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b44.setBackground(new Color(50, 205, 50)); + b44.setFont(new Font("Tahoma", Font.BOLD, 9)); + b44.setBounds(388, 193, 43, 43); + frame.getContentPane().add(b44); + + JButton b43 = new JButton("43"); + b43.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b43)) + { + message.setText("Seat 43 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 43"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b43).setBackground(Color.BLUE); + q.add(b43); + tempq.add(b43); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b43.setBackground(new Color(50, 205, 50)); + b43.setFont(new Font("Tahoma", Font.BOLD, 9)); + b43.setBounds(335, 193, 43, 43); + frame.getContentPane().add(b43); + + JButton b42 = new JButton("42"); + b42.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b42)) + { + message.setText("Seat 42 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 42"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b42).setBackground(Color.BLUE); + q.add(b42); + tempq.add(b42); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b42.setBackground(new Color(50, 205, 50)); + b42.setFont(new Font("Tahoma", Font.BOLD, 9)); + b42.setBounds(386, 140, 43, 43); + frame.getContentPane().add(b42); + + JButton b41 = new JButton("41"); + b41.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + message.setText("Already Booked."); + } + }); + b41.setBackground(new Color(255, 0, 0)); + b41.setFont(new Font("Tahoma", Font.BOLD, 9)); + b41.setBounds(333, 140, 43, 43); + frame.getContentPane().add(b41); + + JButton b51 = new JButton("51"); + b51.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b51)) + { + message.setText("Seat 51 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 51"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b51).setBackground(Color.BLUE); + q.add(b51); + tempq.add(b51); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b51.setBackground(new Color(50, 205, 50)); + b51.setFont(new Font("Tahoma", Font.BOLD, 9)); + b51.setBounds(495, 34, 43, 43); + frame.getContentPane().add(b51); + + JButton b52 = new JButton("52"); + b52.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b52)) + { + message.setText("Seat 52 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 52"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b52).setBackground(Color.BLUE); + q.add(b52); + tempq.add(b52); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b52.setBackground(new Color(50, 205, 50)); + b52.setFont(new Font("Tahoma", Font.BOLD, 9)); + b52.setBounds(548, 34, 43, 43); + frame.getContentPane().add(b52); + + JButton b53 = new JButton("53"); + b53.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + message.setText("Already Booked."); + } + }); + b53.setBackground(new Color(255, 0, 0)); + b53.setFont(new Font("Tahoma", Font.BOLD, 9)); + b53.setBounds(495, 87, 43, 43); + frame.getContentPane().add(b53); + + JButton b54 = new JButton("54"); + b54.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b54)) + { + message.setText("Seat 54 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 54"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b54).setBackground(Color.BLUE); + q.add(b54); + tempq.add(b54); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b54.setBackground(new Color(50, 205, 50)); + b54.setFont(new Font("Tahoma", Font.BOLD, 9)); + b54.setBounds(548, 87, 43, 43); + frame.getContentPane().add(b54); + + JButton b64 = new JButton("64"); + b64.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b64)) + { + message.setText("Seat 64 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 64"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b64).setBackground(Color.BLUE); + q.add(b64); + tempq.add(b64); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b64.setBackground(new Color(50, 205, 50)); + b64.setFont(new Font("Tahoma", Font.BOLD, 9)); + b64.setBounds(548, 193, 43, 43); + frame.getContentPane().add(b64); + + JButton b63 = new JButton("63"); + b63.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b63)) + { + message.setText("Seat 63 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 63"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b63).setBackground(Color.BLUE); + q.add(b63); + tempq.add(b63); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b63.setBackground(new Color(50, 205, 50)); + b63.setFont(new Font("Tahoma", Font.BOLD, 9)); + b63.setBounds(495, 193, 43, 43); + frame.getContentPane().add(b63); + + JButton b62 = new JButton("62"); + b62.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b62)) + { + message.setText("Seat 62 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 62"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b62).setBackground(Color.BLUE); + q.add(b62); + tempq.add(b62); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b62.setBackground(new Color(50, 205, 50)); + b62.setFont(new Font("Tahoma", Font.BOLD, 9)); + b62.setBounds(548, 140, 43, 43); + frame.getContentPane().add(b62); + + JButton b61 = new JButton("61"); + b61.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(!q.contains(b61)) + { + message.setText("Seat 61 selected."); + String res=selected.getText(); + selected.setText(res+", Seat 61"); + ct++; + ticketnum.setText(Integer.toString(ct)); + double temp = ct*price; + (b61).setBackground(Color.BLUE); + q.add(b61); + tempq.add(b61); + totalprice.setText(Double.toString(temp)); + } + else + { + message.setText("Already Booked."); + } + } + }); + b61.setBackground(new Color(50, 205, 50)); + b61.setFont(new Font("Tahoma", Font.BOLD, 9)); + b61.setBounds(495, 140, 43, 43); + frame.getContentPane().add(b61); + + JLabel labelx = new JLabel("Selected Seats :"); + labelx.setFont(new Font("Times New Roman", Font.BOLD, 14)); + labelx.setBounds(31, 347, 106, 26); + frame.getContentPane().add(labelx); + + selected = new JLabel(""); + selected.setFont(new Font("Times New Roman", Font.BOLD, 14)); + selected.setBounds(147, 356, 555, 17); + frame.getContentPane().add(selected); + + message = new JLabel(""); + message.setForeground(new Color(0, 191, 255)); + message.setFont(new Font("Times New Roman", Font.BOLD, 14)); + message.setBounds(172, 299, 202, 17); + frame.getContentPane().add(message); + + JLabel lblNewLabel = new JLabel("No of Tickets: "); + lblNewLabel.setFont(new Font("Times New Roman", Font.BOLD, 14)); + lblNewLabel.setBounds(31, 395, 106, 13); + frame.getContentPane().add(lblNewLabel); + + ticketnum = new JLabel(""); + ticketnum.setFont(new Font("Tahoma", Font.PLAIN, 14)); + ticketnum.setBounds(158, 395, 57, 17); + frame.getContentPane().add(ticketnum); + + JLabel lblNewLabel_1 = new JLabel("Total Price:"); + lblNewLabel_1.setFont(new Font("Times New Roman", Font.BOLD, 14)); + lblNewLabel_1.setBounds(31, 434, 86, 13); + frame.getContentPane().add(lblNewLabel_1); + + totalprice = new JLabel(""); + totalprice.setFont(new Font("Tahoma", Font.PLAIN, 14)); + totalprice.setBounds(158, 434, 68, 19); + frame.getContentPane().add(totalprice); + + JButton pay = new JButton("Confirm and Pay"); + pay.setBackground(SystemColor.activeCaption); + pay.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) + { + if(price!=ct) + { + while(!tempq.isEmpty()) + { + (tempq.poll()).setBackground(Color.RED); + } + + new DisplayTicket(from,to,date,res,key,ct,price,selected.getText()); + } + else + noselection.setText("Please Select Seats...!"); + } + }); + pay.setBounds(31, 473, 202, 26); + frame.getContentPane().add(pay); + + JLabel lblNewLabel_2 = new JLabel("Block - A"); + lblNewLabel_2.setFont(new Font("Tahoma", Font.BOLD, 14)); + lblNewLabel_2.setForeground(new Color(0, 0, 0)); + lblNewLabel_2.setBackground(new Color(240, 240, 240)); + lblNewLabel_2.setBounds(185, 258, 70, 13); + frame.getContentPane().add(lblNewLabel_2); + + JLabel lblNewLabel_2_1 = new JLabel("Block - B"); + lblNewLabel_2_1.setForeground(Color.BLACK); + lblNewLabel_2_1.setFont(new Font("Tahoma", Font.BOLD, 14)); + lblNewLabel_2_1.setBackground(SystemColor.menu); + lblNewLabel_2_1.setBounds(346, 260, 70, 13); + frame.getContentPane().add(lblNewLabel_2_1); + + JLabel lblNewLabel_2_2 = new JLabel("Block - C"); + lblNewLabel_2_2.setForeground(Color.BLACK); + lblNewLabel_2_2.setFont(new Font("Tahoma", Font.BOLD, 14)); + lblNewLabel_2_2.setBackground(SystemColor.menu); + lblNewLabel_2_2.setBounds(507, 260, 70, 13); + frame.getContentPane().add(lblNewLabel_2_2); + + noselection = new JLabel(""); + noselection.setFont(new Font("Tahoma", Font.PLAIN, 14)); + noselection.setForeground(new Color(255, 0, 0)); + noselection.setBounds(31, 509, 304, 30); + frame.getContentPane().add(noselection); + + + + frame.setSize(718,586); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + } +} \ No newline at end of file diff --git a/Comp Crew/Bus_Railway_Routes.java b/Comp Crew/Bus_Railway_Routes.java new file mode 100644 index 0000000..d062bbc --- /dev/null +++ b/Comp Crew/Bus_Railway_Routes.java @@ -0,0 +1,114 @@ +package pkg1; + +public class Bus_Railway_Routes +{ + Node[] arr_routes = new Node[9]; + + public Bus_Railway_Routes() + { + Node ptr; + + arr_routes[0] = new Node("Mumbai","All","12:00 pm",0); + ptr = arr_routes[0]; + ptr.next = new Node("Thane","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Raigad","All","2:00 pm",200); + ptr= ptr.next; + ptr.next = new Node("Ratnagiri","All","3:00 pm",300); + ptr= ptr.next; + ptr.next = new Node("Sindhudurg","All","4:00 pm",400); + + arr_routes[1] = new Node("Mumbai","All","12:00 pm",0); + ptr = arr_routes[1]; + ptr.next = new Node("Thane","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Palghar","All","2:00 pm",200); + + arr_routes[2] = new Node("Mumbai","All","12:00 pm",0); + ptr = arr_routes[2]; + ptr.next = new Node("Thane","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Pune","All","2:00 pm",200); + ptr= ptr.next; + ptr.next = new Node("Satara","All","3:00 pm",300); + ptr= ptr.next; + ptr.next = new Node("Sangli","All","4:00 pm",400); + ptr= ptr.next; + ptr.next = new Node("Kolhapur","All","5:00 pm",500); + + arr_routes[3] = new Node("Pune","All","12:00 pm",0); + ptr = arr_routes[3]; + ptr.next = new Node("Solapur","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Osmanabad","All","2:00 pm",200); + ptr= ptr.next; + ptr.next = new Node("Latur","All","3:00 pm",300); + + arr_routes[4] = new Node("Palghar","All","12:00 pm",0); + ptr = arr_routes[4]; + ptr.next = new Node("Nashik","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Dhule","All","2:00 pm",200); + ptr= ptr.next; + ptr.next = new Node("Jalgaon","All","3:00 pm",300); + + arr_routes[5] = new Node("Nandurbar","All","12:00 pm",0); + ptr = arr_routes[5]; + ptr.next = new Node("Dhule","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Jalgaon","All","2:00 pm",200); + ptr= ptr.next; + ptr.next = new Node("Buldhana","All","3:00 pm",300); + ptr= ptr.next; + ptr.next = new Node("Akola","All","4:00 pm",400); + ptr= ptr.next; + ptr.next = new Node("Amaravati","All","5:00 pm",500); + ptr= ptr.next; + ptr.next = new Node("Wardha","All","6:00 pm",600); + ptr= ptr.next; + ptr.next = new Node("Nagpur","All","7:00 pm",700); + ptr= ptr.next; + ptr.next = new Node("Bhandara","All","8:00 pm",800); + ptr= ptr.next; + ptr.next = new Node("Gondia","All","9:00 pm",900); + + arr_routes[6] = new Node("Ahmadnagar","All","12:00 pm",0); + ptr = arr_routes[6]; + ptr.next = new Node("Beed","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Parbhani","All","2:00 pm",200); + ptr= ptr.next; + ptr.next = new Node("Latur","All","3:00 pm",300); + + arr_routes[7] = new Node("Aurangabad","All","12:00 pm",0); + ptr = arr_routes[7]; + ptr.next = new Node("Buldhana","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Washim","All","2:00 pm",200); + ptr= ptr.next; + ptr.next = new Node("Hingoli","All","3:00 pm",300); + ptr= ptr.next; + ptr.next = new Node("Yavatmal","All","4:00 pm",400); + + arr_routes[8] = new Node("Nagpur","All","12:00 pm",0); + ptr = arr_routes[8]; + ptr.next = new Node("Chandrapur","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Gadchiroli","All","2:00 pm",200); + + /* + for(int i=0;i<9;i++) + { + Node curr= arr_routes[i]; + while(curr!=null) + { + if(curr.next!=null) + System.out.print(curr.name+" ---> "); + else + System.out.print(curr.name); + curr=curr.next; + } + System.out.println("\n"); + }*/ + } +} \ No newline at end of file diff --git a/Comp Crew/Bus_Routes.java b/Comp Crew/Bus_Routes.java new file mode 100644 index 0000000..99e3fe3 --- /dev/null +++ b/Comp Crew/Bus_Routes.java @@ -0,0 +1,365 @@ +package pkg1; + +public class Bus_Routes +{ + Node[] arr_routes = new Node[35]; + + public Bus_Routes() + { + Node ptr; + + arr_routes[0] = new Node("Ahmadnagar","All","",0.0); + ptr = arr_routes[0]; + ptr.next = new Node("Pune","All","3:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Thane","All","3:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Nashik","All","3:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Aurangabad","All","3:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Beed","All","3:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Solapur","All","3:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Osmanabad","All","3:00 pm",100); + + arr_routes[1] = new Node("Akola","All","",0); + ptr = arr_routes[1]; + ptr.next = new Node("Buldhana","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Amravati","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Washim","All","1:00 pm",100); + + arr_routes[2] = new Node("Amravati","All","",0); + ptr = arr_routes[2]; + ptr.next = new Node("Akola","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Washim","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Wardha","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Yavatmal","All","1:00 pm",100); + + arr_routes[3] = new Node("Aurangabad","All","",0); + ptr = arr_routes[3]; + ptr.next = new Node("Nashik","All","2:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Jalgaon","All","2:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Jalna","All","2:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Ahmadnagar","All","2:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Beed","All","2:00 pm",100); + + arr_routes[4] = new Node("Beed","All","",0); + ptr = arr_routes[4]; + ptr.next = new Node("Osmanabad","All","4:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Latur","All","4:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Ahmadnagar","All","4:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Jalna","All","4:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Parbhani","All","4:00 pm",100); + + arr_routes[5] = new Node("Bhandara","All","",0); + ptr = arr_routes[5]; + ptr.next = new Node("Nagpur","All","4:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Gondia","All","4:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Chandrapur","All","4:00 pm",100); + + arr_routes[6] = new Node("Buldhana","All","",0); + ptr = arr_routes[6]; + ptr.next = new Node("Jalgaon","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Jalana","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Washim","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Akola","All","5:00 pm",100); + + arr_routes[7] = new Node("Chandrapur","All","",0); + ptr = arr_routes[7]; + ptr.next = new Node("Yavatmal","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Wardha","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Bhandara","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Gadchiroli","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Nagpur","All","5:00 pm",100); + + arr_routes[8] = new Node("Dhule","All","",0); + ptr = arr_routes[8]; + ptr.next = new Node("Nandurbar","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Nashik","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Jalgaon","All","5:00 pm",100); + + arr_routes[9] = new Node("Gadchiroli","All","",0); + ptr = arr_routes[9]; + ptr.next = new Node("Chandrapur","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Gondia","All","5:00 pm",100); + + arr_routes[10] = new Node("Gondia","All","",0); + ptr = arr_routes[10]; + ptr.next = new Node("Bhandara","All","6:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Gadchiroli","All","6:00 pm",100); + + arr_routes[11] = new Node("Hingoli","All","",0); + ptr = arr_routes[11]; + ptr.next = new Node("Parbhani","All","6:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Washim","All","6:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Yavatmal","All","6:00 pm",100); + + arr_routes[12] = new Node("jalana","All","",0); + ptr = arr_routes[12]; + ptr.next = new Node("Aurangabad","All","6:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Buldhana","All","6:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Parbhani","All","6:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Beed","All","6:00 pm",100); + + arr_routes[13] = new Node("Jalgaon","All","",0); + ptr = arr_routes[13]; + ptr.next = new Node("Buldhana","All","7:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Aurangabad","All","7:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Dhule","All","7:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Nashik","All","7:00 pm",100); + + arr_routes[14] = new Node("Kolhapur","All","",0); + ptr = arr_routes[14]; + ptr.next = new Node("Sangali","All","8:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Ratnagiri","All","8:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Sindhudurg","All","8:00 pm",100); + + arr_routes[15] = new Node("Latur","All","",0); + ptr = arr_routes[15]; + ptr.next = new Node("Parbhani","All","8:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Beed","All","8:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Osmanabad","All","8:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Nanded","All","8:00 pm",100); + + arr_routes[16] = new Node("Mumbai","All","",0); + ptr = arr_routes[16]; + ptr.next = new Node("Thane","All","8:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Palghar","All","8:00 pm",100); + + arr_routes[17] = new Node("Nagpur","All","",0); + ptr = arr_routes[17]; + ptr.next = new Node("Bhandara","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Wardha","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Chandrapur","All","9:00 pm",100); + + arr_routes[18] = new Node("Nanded","All","",0); + ptr = arr_routes[18]; + ptr.next = new Node("Latur","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Parbhani","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Hingoli","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Yavatmal","All","9:00 pm",100); + + arr_routes[19] = new Node("Nandurbar","All","",0); + ptr = arr_routes[19]; + ptr.next = new Node("Dhule","All","9:00 pm",100); + + arr_routes[20] = new Node("Nashik","All","",0); + ptr = arr_routes[20]; + ptr.next = new Node("Ahmadnagar","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Aurangabad","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Jalgaon","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Dhule","All","9:00 pm",100); + + arr_routes[21] = new Node("Osmanabad","All","",0); + ptr = arr_routes[21]; + ptr.next = new Node("Solapur","All","10:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Beed","All","10:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Latur","All","10:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Ahmadnagar","All","10:00 pm",100); + + arr_routes[22] = new Node("Palghar","All","",0); + ptr = arr_routes[22]; + ptr.next = new Node("Nashik","All","10:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Thane","All","10:00 pm",100); + + arr_routes[23] = new Node("Parbhani","All","",0); + ptr = arr_routes[23]; + ptr.next = new Node("Beed","All","11:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Latur","All","11:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Hingoli","All","11:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Jalana","All","11:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Nanded","All","11:00 pm",100); + + arr_routes[24] = new Node("Pune","All","",0); + ptr = arr_routes[24]; + ptr.next = new Node("Raigad","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Satara","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Thane","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Solapur","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Ahmadnagar","All","1:00 pm",100); + + arr_routes[25] = new Node("Raigad","All","",0); + ptr = arr_routes[25]; + ptr.next = new Node("Pune","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Thane","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Satara","All","1:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Ratnagiri","All","1:00 pm",100); + + arr_routes[26] = new Node("Ratnagiri","All","",0); + ptr = arr_routes[26]; + ptr.next = new Node("Raigad","All","3:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Satara","All","3:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Kolhapur","All","3:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Singhudurg","All","3:00 pm",100); + + arr_routes[27] = new Node("Sangli","All","",0); + ptr = arr_routes[27]; + ptr.next = new Node("Solapur","All","3:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Satara","All","3:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Kolhapur","All","3:00 pm",100); + + arr_routes[28] = new Node("Satara","All","",0); + ptr = arr_routes[28]; + ptr.next = new Node("Raigad","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Pune","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Ratnagiri","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Solapur","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Sangli","All","5:00 pm",100); + + arr_routes[29] = new Node("Sindhudurg","All","",0); + ptr = arr_routes[29]; + ptr.next = new Node("Ratnagiri","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Kolhapur","All","5:00 pm",100); + + arr_routes[30] = new Node("Solapur","All","",0); + ptr = arr_routes[30]; + ptr.next = new Node("Sangli","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Satara","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Pune","All","5:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Ahmadnagar","All","5:00 pm",100); + ptr = ptr.next; + ptr.next = new Node("Osmanabad","All","5:00 pm",100); + + arr_routes[31] = new Node("Thane","All","",0); + ptr = arr_routes[31]; + ptr.next = new Node("Mumbai","All","7:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Raigad","All","7:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Pune","All","7:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Ahmadnagar","All","7:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Nashik","All","7:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Palghar","All","7:00 pm",100); + + arr_routes[32] = new Node("Wardha","All","",0); + ptr = arr_routes[32]; + ptr.next = new Node("Amravati","All","7:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Chandrapur","All","7:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Nagpur","All","7:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Yavatmal","All","7:00 pm",100); + + arr_routes[33] = new Node("Washim","All","",0); + ptr = arr_routes[33]; + ptr.next = new Node("Buldhana","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Akola","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Hingoli","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Yavatmal","All","9:00 pm",100); + + arr_routes[34] = new Node("Yavatmal","All","",0); + ptr = arr_routes[34]; + ptr.next = new Node("Amravati","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Washim","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Hingoli","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Nanded","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Wardha","All","9:00 pm",100); + ptr= ptr.next; + ptr.next = new Node("Chandrapur","All","9:00 pm",100); + + /* + for(int i=0;i<35;i++) + { + Node curr= arr_routes[i]; + while(curr!=null) + { + if(curr.next!=null) + System.out.print(curr.name+" ---> "); + else + System.out.print(curr.name); + + curr=curr.next; + } + System.out.println("\n"); + }*/ + } +} \ No newline at end of file diff --git a/Comp Crew/DisplayTicket.java b/Comp Crew/DisplayTicket.java new file mode 100644 index 0000000..4a64cfa --- /dev/null +++ b/Comp Crew/DisplayTicket.java @@ -0,0 +1,96 @@ +package pkg1; + +import java.awt.Color; +import java.awt.Font; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import java.awt.Window.Type; +import javax.swing.JButton; +import java.awt.SystemColor; +import javax.swing.UIManager; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +public class DisplayTicket +{ + static JFrame frame; + String ticket=""; + static JLabel successmsg; + + DisplayTicket(String from,String to,String date,String res,int key,int ct,double price,String seats) + { + frame = new JFrame(); + frame.setType(Type.POPUP); + frame.setAlwaysOnTop(true); + frame.getContentPane().setBackground(new Color(240, 240, 240)); + frame.getContentPane().setFont(new Font("Tahoma", Font.PLAIN, 14)); + frame.getContentPane().setLayout(null); + + ticket="Date: "+date+"|No.of Tickets: "+ct+"|Total Price = "+price+"|Seats: "+seats; + + //UserData obj = new UserData(key,res,ticket); + + JLabel lblNewLabel = new JLabel("Booked Ticket Successfully..!"); + lblNewLabel.setBackground(new Color(240, 240, 240)); + lblNewLabel.setForeground(new Color(50, 205, 50)); + lblNewLabel.setFont(new Font("Times New Roman", Font.BOLD, 18)); + lblNewLabel.setBounds(53, 51, 366, 26); + frame.getContentPane().add(lblNewLabel); + + JLabel reslabel = new JLabel(res); + reslabel.setBackground(new Color(0, 255, 255)); + reslabel.setFont(new Font("Times New Roman", Font.BOLD, 14)); + reslabel.setBounds(53, 87, 671, 36); + frame.getContentPane().add(reslabel); + + JLabel ticketlabel = new JLabel(ticket); + ticketlabel.setFont(new Font("Times New Roman", Font.BOLD, 14)); + ticketlabel.setBackground(new Color(0, 255, 255)); + ticketlabel.setBounds(53, 118, 671, 36); + frame.getContentPane().add(ticketlabel); + + JButton btnNewButton = new JButton("Your Bookings"); + btnNewButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) + { + if((UserData.hashtable[key].booking).equals("No Bookings")) + { + UserData.hashtable[key].booking = res; + UserData.hashtable[key].ticket = ticket; + } + else + { + UserData.hashtable[key].booking = (UserData.hashtable[key].booking)+" && "+res; + UserData.hashtable[key].ticket = UserData.hashtable[key].ticket+" && "+ticket; + } + new YourBookings(key); + frame.dispose(); + } + }); + btnNewButton.setBackground(SystemColor.activeCaption); + btnNewButton.setForeground(SystemColor.activeCaptionText); + btnNewButton.setBounds(53, 227, 133, 26); + frame.getContentPane().add(btnNewButton); + + JButton btnPrintTicket = new JButton("Print Ticket"); + btnPrintTicket.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + successmsg.setText("Ticket Printed..!"); + } + }); + btnPrintTicket.setForeground(Color.BLACK); + btnPrintTicket.setBackground(SystemColor.activeCaption); + btnPrintTicket.setBounds(53, 164, 133, 26); + frame.getContentPane().add(btnPrintTicket); + + successmsg = new JLabel(""); + successmsg.setForeground(new Color(50, 205, 50)); + successmsg.setBounds(53, 200, 414, 17); + frame.getContentPane().add(successmsg); + + frame.setSize(788,500); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + } +} diff --git a/Comp Crew/Display_Bus.java b/Comp Crew/Display_Bus.java new file mode 100644 index 0000000..0fb68d8 --- /dev/null +++ b/Comp Crew/Display_Bus.java @@ -0,0 +1,251 @@ +package pkg1; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.awt.Dialog.ModalExclusionType; + + +public class Display_Bus +{ + static JFrame frame; + JLabel label1; + JButton btn1; + JButton btn2; + static JButton bus1; + static JButton bus2; + static JButton bus3; + static JButton bus4; + static JButton bus5; + static JButton bus6; + static JButton bus7; + private JLabel datelabel; + private JLabel message; + static String res1="",res2="",res3="",res4="",res5="",res6="",res7=""; + static double price1=0,price2=0,price3=0,price4=0,price5=0,price6=0,price7=0; + static int key; + + Display_Bus(String from,String to,String date,int key) + { + this.key=key; + frame = new JFrame(); + frame.getContentPane().setBackground(new Color(240, 240, 240)); + frame.getContentPane().setFont(new Font("Tahoma", Font.PLAIN, 14)); + frame.getContentPane().setLayout(null); + + label1 = new JLabel("Available Buses"); + label1.setForeground(new Color(0, 0, 0)); + label1.setBackground(new Color(255, 255, 255)); + label1.setFont(new Font("Britannic Bold", Font.PLAIN, 30)); + label1.setBounds(25, 10, 225, 45); + frame.getContentPane().add(label1); + + JLabel routelabel = new JLabel("From "+from+" to "+to); + routelabel.setForeground(SystemColor.desktop); + routelabel.setFont(new Font("Britannic Bold", Font.PLAIN, 18)); + routelabel.setBounds(25, 53, 440, 42); + frame.getContentPane().add(routelabel); + + datelabel = new JLabel("Date : "+date); + datelabel.setForeground(SystemColor.desktop); + datelabel.setFont(new Font("Britannic Bold", Font.PLAIN, 18)); + datelabel.setBounds(407, 56, 164, 36); + frame.getContentPane().add(datelabel); + + message = new JLabel("Click on bus to book"); + message.setFont(new Font("Times New Roman", Font.PLAIN, 14)); + message.setBounds(25, 121, 285, 13); + frame.getContentPane().add(message); + + bus1 = new JButton("Not Available"); + bus1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) + { + new BookBus(from,to,date,res1,key,price1); + } + }); + bus1.setBackground(SystemColor.activeCaption); + bus1.setBounds(25, 143, 705, 21); + frame.getContentPane().add(bus1); + + bus2 = new JButton("Not Available"); + bus2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookBus(from,to,date,res2,key,price2); + } + }); + bus2.setForeground(new Color(0, 0, 0)); + bus2.setBackground(SystemColor.activeCaption); + bus2.setBounds(25, 189, 705, 21); + frame.getContentPane().add(bus2); + + bus3 = new JButton("Not Available"); + bus3.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookBus(from,to,date,res3,key,price3); + } + }); + bus3.setForeground(Color.BLACK); + bus3.setBackground(SystemColor.activeCaption); + bus3.setBounds(25, 236, 705, 21); + frame.getContentPane().add(bus3); + + bus4 = new JButton("Not Available"); + bus4.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookBus(from,to,date,res4,key,price4); + } + }); + bus4.setForeground(Color.BLACK); + bus4.setBackground(SystemColor.activeCaption); + bus4.setBounds(25, 282, 705, 21); + frame.getContentPane().add(bus4); + + bus5 = new JButton("Not Available"); + bus5.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookBus(from,to,date,res5,key,price5); + } + }); + bus5.setForeground(Color.BLACK); + bus5.setBackground(SystemColor.activeCaption); + bus5.setBounds(25, 329, 705, 21); + frame.getContentPane().add(bus5); + + bus6 = new JButton("Not Available"); + bus6.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookBus(from,to,date,res6,key,price6); + } + }); + bus6.setForeground(Color.BLACK); + bus6.setBackground(SystemColor.activeCaption); + bus6.setBounds(25, 375, 705, 21); + frame.getContentPane().add(bus6); + + bus7 = new JButton("Not Available"); + bus7.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookBus(from,to,date,res7,key,price7); + } + }); + bus7.setForeground(Color.BLACK); + bus7.setBackground(SystemColor.activeCaption); + bus7.setBounds(25, 419, 705, 21); + frame.getContentPane().add(bus7); + + + CheckForBuses(from, to, date, key); + + frame.setSize(785,499); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + } + + static void CheckForBuses(String from,String to,String date,int key) + { + Bus_Routes obj=new Bus_Routes(); + Bus_Railway_Routes obj2=new Bus_Railway_Routes(); + int ct=1; + + //Code to display bus routes + for(int i=0;i<35;i++) + { + if( (obj.arr_routes[i].name).equals(from) ) + { + Node ptr = obj.arr_routes[i]; + while(ptr.next!=null) + { + if((ptr.next.name).equals(to)) + { + res1 = "Bus1 : "+from+" To "+to+" | Time: "+ptr.next.time+" | Ticket Price : 100"; + price1=100; + bus1.setText(res1); + ct++; + break; + } + ptr = ptr.next; + } + } + } + + //code to display bus railway routes + for(int i=0;i<9;i++) + { + Node ptr2 = obj2.arr_routes[i]; + String start = ptr2.name; + String fromtime = ""; + double fromprice=0; + double toprice=0; + String last=""; + int flag=0; + + while(ptr2!=null) + { + if((ptr2.name).equals(from)) + { + fromtime=ptr2.time; + fromprice = ptr2.price; + flag=1; + } + if((ptr2.name).equals(to)) + { + toprice = ptr2.price; + flag=2; + } + + last=ptr2.name; + ptr2=ptr2.next; + } + + if(flag==2) + { + if(ct==2) + { + res2="Bus2 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price2=(toprice-fromprice); + bus2.setText(res2); + ct++; + } + else if(ct==3) + { + res3 = "Bus3 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price3=(toprice-fromprice); + bus3.setText(res3); + ct++; + } + else if(ct==4) + { + res4="Bus4 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price4=(toprice-fromprice); + bus4.setText(res4); + ct++; + } + else if(ct==5) + { + res5="Bus5 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price5=(toprice-fromprice); + bus5.setText(res5); + ct++; + } + else if(ct==6) + { + res6="Bus6 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price6=(toprice-fromprice); + bus6.setText(res6); + ct++; + } + else if(ct==7) + { + res7="Bus7 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price7=(toprice-fromprice); + bus7.setText(res7); + ct++; + } + else + { + break; + } + } + } + } +} diff --git a/Comp Crew/Display_Train.java b/Comp Crew/Display_Train.java new file mode 100644 index 0000000..3fafdf2 --- /dev/null +++ b/Comp Crew/Display_Train.java @@ -0,0 +1,233 @@ +package pkg1; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.awt.Dialog.ModalExclusionType; + + +public class Display_Train +{ + static JFrame frame; + JLabel label1; + JButton btn1; + JButton btn2; + static JButton tr1; + static JButton tr2; + static JButton tr3; + static JButton tr4; + static JButton tr5; + static JButton tr6; + static JButton tr7; + private JLabel datelabel; + private JLabel message; + static String res1="",res2="",res3="",res4="",res5="",res6="",res7=""; + static double price1=0,price2=0,price3=0,price4=0,price5=0,price6=0,price7=0; + + Display_Train(String from,String to,String date,int key) + { + frame = new JFrame(); + frame.getContentPane().setBackground(new Color(240, 240, 240)); + frame.getContentPane().setFont(new Font("Tahoma", Font.PLAIN, 14)); + frame.getContentPane().setLayout(null); + + label1 = new JLabel("Available Trains"); + label1.setForeground(new Color(0, 0, 0)); + label1.setBackground(new Color(255, 255, 255)); + label1.setFont(new Font("Britannic Bold", Font.PLAIN, 30)); + label1.setBounds(25, 10, 225, 45); + frame.getContentPane().add(label1); + + JLabel routelabel = new JLabel("From "+from+" to "+to); + routelabel.setForeground(SystemColor.desktop); + routelabel.setFont(new Font("Britannic Bold", Font.PLAIN, 18)); + routelabel.setBounds(25, 53, 440, 42); + frame.getContentPane().add(routelabel); + + datelabel = new JLabel("Date : "+date); + datelabel.setForeground(SystemColor.desktop); + datelabel.setFont(new Font("Britannic Bold", Font.PLAIN, 18)); + datelabel.setBounds(407, 56, 164, 36); + frame.getContentPane().add(datelabel); + + message = new JLabel("Click on train to book"); + message.setFont(new Font("Times New Roman", Font.PLAIN, 14)); + message.setBounds(25, 121, 285, 13); + frame.getContentPane().add(message); + + tr1 = new JButton("Not Available"); + tr1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookRailway(from,to,date,res1,key,price1); + } + }); + tr1.setBackground(SystemColor.activeCaption); + tr1.setBounds(25, 143, 705, 21); + frame.getContentPane().add(tr1); + + tr2 = new JButton("Not Available"); + tr2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookRailway(from,to,date,res2,key,price2); + } + }); + tr2.setForeground(new Color(0, 0, 0)); + tr2.setBackground(SystemColor.activeCaption); + tr2.setBounds(25, 189, 705, 21); + frame.getContentPane().add(tr2); + + tr3 = new JButton("Not Available"); + tr3.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookRailway(from,to,date,res3,key,price3); + } + }); + tr3.setForeground(Color.BLACK); + tr3.setBackground(SystemColor.activeCaption); + tr3.setBounds(25, 236, 705, 21); + frame.getContentPane().add(tr3); + + tr4 = new JButton("Not Available"); + tr4.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookRailway(from,to,date,res4,key,price4); + } + }); + tr4.setForeground(Color.BLACK); + tr4.setBackground(SystemColor.activeCaption); + tr4.setBounds(25, 282, 705, 21); + frame.getContentPane().add(tr4); + + tr5 = new JButton("Not Available"); + tr5.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookRailway(from,to,date,res5,key,price5); + } + }); + tr5.setForeground(Color.BLACK); + tr5.setBackground(SystemColor.activeCaption); + tr5.setBounds(25, 329, 705, 21); + frame.getContentPane().add(tr5); + + tr6 = new JButton("Not Available"); + tr6.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookRailway(from,to,date,res6,key,price6); + } + }); + tr6.setForeground(Color.BLACK); + tr6.setBackground(SystemColor.activeCaption); + tr6.setBounds(25, 375, 705, 21); + frame.getContentPane().add(tr6); + + tr7 = new JButton("Not Available"); + tr7.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new BookRailway(from,to,date,res7,key,price7); + } + }); + tr7.setForeground(Color.BLACK); + tr7.setBackground(SystemColor.activeCaption); + tr7.setBounds(25, 419, 705, 21); + frame.getContentPane().add(tr7); + + + CheckForBuses(from, to, date, key); + + frame.setSize(785,499); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + } + + static void CheckForBuses(String from,String to,String date,int key) + { + Bus_Railway_Routes obj=new Bus_Railway_Routes(); + int ct=1; + + //code to display bus railway routes + for(int i=0;i<9;i++) + { + Node ptr2 = obj.arr_routes[i]; + String start = ptr2.name; + String fromtime = ""; + double fromprice=0; + double toprice=0; + String last=""; + int flag=0; + + while(ptr2!=null) + { + if((ptr2.name).equals(from)) + { + fromtime=ptr2.time; + fromprice = ptr2.price; + flag=1; + } + if((ptr2.name).equals(to)) + { + toprice = ptr2.price; + flag=2; + } + + last=ptr2.name; + ptr2=ptr2.next; + } + + if(flag==2) + { + if(ct==1) + { + res1="Train1 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price1=(toprice-fromprice); + tr1.setText(res1); + ct++; + } + else if(ct==2) + { + res2="Train2 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price2=(toprice-fromprice); + tr2.setText(res2); + ct++; + } + else if(ct==3) + { + res3="Train3 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price3=(toprice-fromprice); + tr3.setText(res3); + ct++; + } + else if(ct==4) + { + res4="Train4 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price4=(toprice-fromprice); + tr4.setText(res4); + ct++; + } + else if(ct==5) + { + res5="Train5 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price5=(toprice-fromprice); + tr5.setText(res5); + ct++; + } + else if(ct==6) + { + res6="Train6 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price6=(toprice-fromprice); + tr6.setText(res6); + ct++; + } + else if(ct==7) + { + res7="Train7 : "+start+" To "+last+" | Time: "+fromtime+"("+from+") | Ticket Price : "+(toprice-fromprice); + price7=(toprice-fromprice); + tr7.setText(res7); + ct++; + } + else + { + break; + } + } + } + } +} diff --git a/Comp Crew/Final_Video.mp4 b/Comp Crew/Final_Video.mp4 new file mode 100644 index 0000000..fb5af7f Binary files /dev/null and b/Comp Crew/Final_Video.mp4 differ diff --git a/Comp Crew/FirstPage.java b/Comp Crew/FirstPage.java new file mode 100644 index 0000000..18e71f7 --- /dev/null +++ b/Comp Crew/FirstPage.java @@ -0,0 +1,109 @@ +package pkg1; + +import java.awt.*; +import java.awt.event.ActionEvent; + +import javax.swing.*; +import java.awt.event.ActionListener; + +public class FirstPage +{ + JFrame frame; + JLabel label1; + JButton btn1; + JButton btn2; + private JTextField txtEnterId; + private JTextField txtEnterPassword; + JLabel signInRes; + + FirstPage() + { + frame = new JFrame(); + frame.getContentPane().setFont(new Font("Tahoma", Font.PLAIN, 14)); + frame.getContentPane().setLayout(null); + + label1 = new JLabel("Welocome To Bus_Railway Reservation System..!!"); + label1.setForeground(new Color(0, 0, 0)); + label1.setBackground(new Color(255, 255, 255)); + label1.setFont(new Font("Britannic Bold", Font.PLAIN, 14)); + label1.setBounds(23, 0, 317, 44); + frame.getContentPane().add(label1); + + JLabel lblNewLabel = new JLabel("Email Id : "); + lblNewLabel.setFont(new Font("Times New Roman", Font.PLAIN, 14)); + lblNewLabel.setBounds(74, 54, 72, 35); + frame.getContentPane().add(lblNewLabel); + + JLabel lblNewLabel_1 = new JLabel("Password : "); + lblNewLabel_1.setFont(new Font("Times New Roman", Font.PLAIN, 14)); + lblNewLabel_1.setBounds(74, 99, 72, 22); + frame.getContentPane().add(lblNewLabel_1); + + txtEnterId = new JTextField(); + txtEnterId.setForeground(Color.GRAY); + txtEnterId.setToolTipText(""); + txtEnterId.setBounds(159, 63, 96, 19); + frame.getContentPane().add(txtEnterId); + txtEnterId.setColumns(10); + + txtEnterPassword = new JTextField(); + txtEnterPassword.setForeground(Color.GRAY); + txtEnterPassword.setBounds(159, 98, 96, 19); + frame.getContentPane().add(txtEnterPassword); + txtEnterPassword.setColumns(10); + + signInRes = new JLabel(""); + signInRes.setFont(new Font("Tahoma", Font.BOLD, 12)); + signInRes.setForeground(new Color(255, 0, 0)); + signInRes.setBounds(74, 172, 244, 30); + frame.getContentPane().add(signInRes); + + JButton btnNewButton = new JButton("Sign In"); + btnNewButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + String id= txtEnterId.getText(); + String pw= txtEnterPassword.getText(); + + UserData obj=new UserData(); + int key = obj.Check(id,pw); + + if(key!=-1) + { + //call homepage + new Homepage(key); + frame.dispose(); + } + else + { + signInRes.setText("Wrong Email-id or Password..!"); + } + } + }); + btnNewButton.setBackground(UIManager.getColor("Button.background")); + btnNewButton.setBounds(72, 141, 85, 21); + frame.getContentPane().add(btnNewButton); + + JButton btnNewButton_1 = new JButton("Sign Up"); + btnNewButton_1.setBackground(UIManager.getColor("Button.background")); + btnNewButton_1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + new Registration(); + frame.dispose(); + } + }); + btnNewButton_1.setBounds(170, 141, 85, 21); + frame.getContentPane().add(btnNewButton_1); + + frame.setSize(378,249); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } + + public static void main(String[] args) + { + new UserData(); + new FirstPage(); + } +} \ No newline at end of file diff --git a/Comp Crew/Homepage.java b/Comp Crew/Homepage.java new file mode 100644 index 0000000..4e0aa03 --- /dev/null +++ b/Comp Crew/Homepage.java @@ -0,0 +1,194 @@ +package pkg1; +//package winBuilder; + +import java.awt.EventQueue; +import javax.swing.JFrame; +import javax.swing.JButton; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import javax.swing.JLabel; +import java.awt.Color; +import java.awt.Font; +import javax.swing.JTextField; +import java.awt.SystemColor; + +public class Homepage implements ActionListener +{ + + //private static final AbstractButton success = null; + private JFrame frame; + private JTextField fromtext; + private JTextField totext; + private JTextField datetext; + JLabel emptyfrom; + JLabel emptyto; + JLabel emptydate; + static int key=-1; + + /** + * Launch the application. + */ + public static void main(String[] args) + { + EventQueue.invokeLater(new Runnable() + { + public void run() + { + try { + Homepage window = new Homepage(); + window.frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the application. + */ + public Homepage(int key) { + this.key=key; + new Homepage(); + } + + public Homepage() + { + initialize(); + } + + /** + * Initialize the contents of the frame. + */ + private void initialize () + { + frame = new JFrame(); + frame.getContentPane().setFont(new Font("Tahoma", Font.BOLD, 15)); + frame.setBounds(100, 100, 610, 466); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.getContentPane().setLayout(null); + + JButton DisplayBusBtn = new JButton("Bus"); + DisplayBusBtn.setForeground(new Color(0, 0, 0)); + DisplayBusBtn.setFont(new Font("Tahoma", Font.PLAIN, 25)); + DisplayBusBtn.setBackground(new Color(153, 180, 209)); + DisplayBusBtn.setBounds(31, 348, 119, 34); + DisplayBusBtn.addActionListener(this); + frame.getContentPane().add(DisplayBusBtn); + + JLabel lblNewLabel = new JLabel("BOOK TICKET"); + lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 35)); + lblNewLabel.setBounds(160, 0, 246, 58); + frame.getContentPane().add(lblNewLabel); + + JButton DisplayTrainBtn = new JButton("Train\r\n"); + DisplayTrainBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) + { + String From =fromtext.getText(); + String To=totext.getText(); + String Date=datetext.getText(); + new Display_Train(From,To,Date,key); + } + }); + DisplayTrainBtn.setBackground(SystemColor.activeCaption); + DisplayTrainBtn.setFont(new Font("Tahoma", Font.ITALIC, 25)); + DisplayTrainBtn.setBounds(172, 348, 132, 34); + frame.getContentPane().add(DisplayTrainBtn); + + JLabel lblNewLabel_1 = new JLabel("From* :"); + lblNewLabel_1.setForeground(new Color(0, 0, 0)); + lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 25)); + lblNewLabel_1.setBounds(59, 90, 142, 45); + frame.getContentPane().add(lblNewLabel_1); + + JLabel lblNewLabel_2 = new JLabel("To* :"); + lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 25)); + lblNewLabel_2.setBounds(59, 158, 72, 50); + frame.getContentPane().add(lblNewLabel_2); + + fromtext = new JTextField(); + fromtext.setToolTipText(""); + fromtext.setFont(new Font("Tahoma", Font.PLAIN, 14)); + fromtext.setForeground(Color.GRAY); + fromtext.setText("e.g. Mumbai"); + fromtext.setBounds(172, 100, 362, 34); + frame.getContentPane().add(fromtext); + fromtext.setColumns(10); + + totext = new JTextField(); + totext.setText("e.g. Satara"); + totext.setForeground(Color.GRAY); + totext.setFont(new Font("Tahoma", Font.PLAIN, 14)); + totext.setBounds(172, 171, 362, 34); + frame.getContentPane().add(totext); + totext.setColumns(10); + + JLabel lblNewLabel_3 = new JLabel("Date* :"); + lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 25)); + lblNewLabel_3.setBounds(59, 242, 102, 40); + frame.getContentPane().add(lblNewLabel_3); + + datetext = new JTextField(); + datetext.setForeground(Color.GRAY); + datetext.setFont(new Font("Tahoma", Font.PLAIN, 14)); + datetext.setText("DD/MM/YYYY"); + datetext.setBounds(172, 250, 362, 34); + frame.getContentPane().add(datetext); + datetext.setColumns(10); + + JButton YourBookingsBtn = new JButton("Your Bookings"); + YourBookingsBtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) + { + new YourBookings(key); + } + }); + YourBookingsBtn.setBackground(SystemColor.activeCaption); + YourBookingsBtn.setFont(new Font("Tahoma", Font.ITALIC, 25)); + YourBookingsBtn.setBounds(327, 348, 209, 34); + frame.getContentPane().add(YourBookingsBtn); + + JLabel success =new JLabel(""); + success.setBounds(10,20,300,45); + frame.getContentPane().add(success); + + emptyfrom = new JLabel(""); + emptyfrom.setForeground(new Color(255, 0, 0)); + emptyfrom.setFont(new Font("Tahoma", Font.PLAIN, 14)); + emptyfrom.setBounds(172, 142, 266, 19); + frame.getContentPane().add(emptyfrom); + + emptyto = new JLabel(""); + emptyto.setForeground(new Color(255, 0, 0)); + emptyto.setFont(new Font("Tahoma", Font.PLAIN, 14)); + emptyto.setBounds(172, 204, 266, 27); + frame.getContentPane().add(emptyto); + + emptydate = new JLabel(""); + emptydate.setForeground(new Color(255, 0, 0)); + emptydate.setFont(new Font("Tahoma", Font.PLAIN, 14)); + emptydate.setBounds(172, 294, 45, 13); + frame.getContentPane().add(emptydate); + + frame.setVisible(true); + } + + @Override + public void actionPerformed(ActionEvent e) + { + String From =fromtext.getText(); + String To=totext.getText(); + String Date=datetext.getText(); + + if(From.equals("")) + emptyfrom.setText("Required field"); + if(To.equals("")) + emptyto.setText("Required field"); + if(Date.equals("")) + emptydate.setText("Required field"); + + if(!From.equals("") && !To.equals("") && !Date.equals("")) + new Display_Bus(From,To,Date,key); + } +} \ No newline at end of file diff --git a/Comp Crew/Node.java b/Comp Crew/Node.java new file mode 100644 index 0000000..e3e07c8 --- /dev/null +++ b/Comp Crew/Node.java @@ -0,0 +1,19 @@ +package pkg1; + +public class Node +{ + String name; + Node next; + String day; + String time; + double price; + + public Node(String name, String day, String time,double price) + { + this.name=name; + this.day=day; + this.time=time; + this.price=price; + next=null; + } +} \ No newline at end of file diff --git a/Comp Crew/README.md b/Comp Crew/README.md new file mode 100644 index 0000000..f266194 --- /dev/null +++ b/Comp Crew/README.md @@ -0,0 +1,8 @@ +# Buffer_3.0 +Buffer 3.0 Repository to submit your projects +# Project Name - +Ticket Reservation System +# Pitch Video - +https://drive.google.com/file/d/156AhwppOs7zW8-m_dNjXmq8ZHulmoKHx/view?usp=sharing +# Project Source Code - +https://drive.google.com/drive/folders/1Guemdz0PstyWD7Gsvb9hNJgnviSNKPnK?usp=sharing diff --git a/Comp Crew/Registration.java b/Comp Crew/Registration.java new file mode 100644 index 0000000..5e1a995 --- /dev/null +++ b/Comp Crew/Registration.java @@ -0,0 +1,110 @@ +package pkg1; + +import java.awt.Font; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JTextField; +import java.awt.SystemColor; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.Color; + +public class Registration +{ + JFrame frame; + + String name,id,pw; + int key=1; + private JTextField nameinput; + private JTextField idinput; + private JTextField pwinput; + JLabel reslabel; + + Registration() + { + frame = new JFrame(); + frame.getContentPane().setFont(new Font("Tahoma", Font.PLAIN, 14)); + frame.getContentPane().setLayout(null); + + JLabel lblNewLabel = new JLabel("Create Account"); + lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 16)); + lblNewLabel.setBounds(51, 25, 147, 20); + frame.getContentPane().add(lblNewLabel); + + JLabel lblNewLabel_1 = new JLabel("Name :"); + lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 12)); + lblNewLabel_1.setBounds(51, 55, 45, 13); + frame.getContentPane().add(lblNewLabel_1); + + JLabel lblNewLabel_2 = new JLabel("Email id :"); + lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 12)); + lblNewLabel_2.setBounds(51, 84, 67, 13); + frame.getContentPane().add(lblNewLabel_2); + + JLabel lblNewLabel_3 = new JLabel("Set Password :"); + lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 12)); + lblNewLabel_3.setBounds(51, 114, 90, 13); + frame.getContentPane().add(lblNewLabel_3); + + JButton createAccBtn = new JButton("Create Account"); + createAccBtn.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + name= nameinput.getText(); + id= idinput.getText(); + pw= pwinput.getText(); + + UserData obj=new UserData(); + int flag = obj.UserDataStorage(name,id,pw,key); + + if(flag==0) + { + reslabel.setText("Account Created Successfully..!"); + new Homepage(key); + } + else + reslabel.setText("Account already exists.\nPlease sign in or use another Email-id\nto create new account."); + key++; + frame.dispose(); + } + }); + createAccBtn.setBackground(SystemColor.activeCaption); + createAccBtn.setFont(new Font("Tahoma", Font.BOLD, 11)); + createAccBtn.setBounds(51, 149, 123, 21); + frame.getContentPane().add(createAccBtn); + + nameinput = new JTextField(); + nameinput.setBounds(106, 53, 186, 19); + frame.getContentPane().add(nameinput); + nameinput.setColumns(10); + + idinput = new JTextField(); + idinput.setBounds(106, 82, 186, 19); + frame.getContentPane().add(idinput); + idinput.setColumns(10); + + pwinput = new JTextField(); + pwinput.setBounds(140, 112, 152, 19); + frame.getContentPane().add(pwinput); + pwinput.setColumns(10); + + reslabel = new JLabel(""); + reslabel.setForeground(new Color(60, 179, 113)); + reslabel.setFont(new Font("Tahoma", Font.BOLD, 12)); + reslabel.setBounds(51, 180, 301, 57); + frame.getContentPane().add(reslabel); + + + frame.setSize(376,284); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } + + public static void main(String args[]) + { + new Registration(); + } +} \ No newline at end of file diff --git a/Comp Crew/UserData.java b/Comp Crew/UserData.java new file mode 100644 index 0000000..87284cb --- /dev/null +++ b/Comp Crew/UserData.java @@ -0,0 +1,99 @@ +package pkg1; + +public class UserData +{ + String name,id,pw; + static Account[] hashtable=new Account[10]; + + UserData(int key) + { + //empty constructor + } + + + UserData(int key,String res,String ticket) + { + hashtable[key].booking=res; + hashtable[key].ticket=ticket; + } + + UserData() + { + for(int i=0;i<10;i++) + { + hashtable[i] = new Account(); + } + + hashtable[0] = new Account("admin","admin@google","123",0); + } + + int UserDataStorage(String name, String id, String pw,int key) + { + int flag=0; + + if(key!=0) + { + for(int i=key;i>=0;i--) + { + if((hashtable[i].id).equals(id)) + { + return flag; + } + } + } + + hashtable[key] = new Account(name,id,pw,key); + return flag;//new Registration("Account Created Successfully..!"); + } + + int Check(String id,String pw) + { + int i=0; + int key=-1; + + while(hashtable[i].key!=-1 && i<10) + { + if((hashtable[i].id).equals(id) && (hashtable[i].pw).equals(pw)) + key = hashtable[i].key; + i++; + } + return key; + + } + + String getbooking(int key) + { + return hashtable[key].booking; + } + + String getticket(int key) + { + return hashtable[key].ticket; + } +} + +class Account +{ + String name="",id="",pw="",booking="",ticket=""; + int key=-1; + + public Account() + { + this.name=""; + this.id=""; + this.pw=""; + this.key=-1; + this.booking=""; + this.ticket=""; + } + + public Account(String name, String id, String pw,int key) + { + this.name=name; + this.id=id; + this.pw=pw; + this.key=key; + this.booking="No Bookings"; + this.ticket=""; + } +} \ No newline at end of file diff --git a/Comp Crew/YourBookings.java b/Comp Crew/YourBookings.java new file mode 100644 index 0000000..664d820 --- /dev/null +++ b/Comp Crew/YourBookings.java @@ -0,0 +1,64 @@ +package pkg1; +//package winBuilder; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.EventQueue; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import javax.swing.JLabel; +import java.awt.Font; +import javax.swing.JButton; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.Window.Type; +import java.awt.SystemColor; + +public class YourBookings +{ + static JFrame frame = new JFrame(); + + + public YourBookings(int key) + { + frame.setType(Type.POPUP); + frame.setAlwaysOnTop(true); + frame.getContentPane().setBackground(new Color(240, 240, 240)); + frame.getContentPane().setFont(new Font("Tahoma", Font.PLAIN, 14)); + frame.getContentPane().setLayout(null); + + JLabel lblNewLabel = new JLabel("Your Bookings:"); + lblNewLabel.setFont(new Font("Tw Cen MT Condensed Extra Bold", Font.PLAIN, 30)); + lblNewLabel.setBounds(32, 36, 650, 39); + frame.getContentPane().add(lblNewLabel); + + JButton bookingbtn = new JButton("Click on the button to see booking"); + bookingbtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + bookingbtn.setText(UserData.hashtable[key].booking); + } + }); + bookingbtn.setBackground(SystemColor.activeCaption); + bookingbtn.setFont(new Font("Tahoma", Font.BOLD, 12)); + bookingbtn.setBounds(10, 99, 888, 51); + frame.getContentPane().add(bookingbtn); + + JButton back = new JButton("Back"); + back.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) + { + bookingbtn.setText("Click on the button to see booking"); + frame.dispose(); + } + }); + back.setFont(new Font("Times New Roman", Font.BOLD, 14)); + back.setBounds(10, 160, 109, 28); + frame.getContentPane().add(back); + + frame.setSize(922,499); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + } +} \ No newline at end of file