Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Code in java using netbeans: Flight Scheduler Initial Phase - Programming Assign

ID: 3778604 • Letter: C

Question

Code in java using netbeans:

Flight Scheduler Initial Phase - Programming Assignment 6 You have been asked to develop a Flight Scheduling application for the Fly-By-Night Airline. The Airline has one or more flights per day but they are not by time. Every Flight will be available for each day the airline flies. The customer gets booked on a specific flight for a specific day. Each Flight has a name and a number of seats on the flight. Each date is just a specific day. The Customer is identified by a single name. This application should have a very nice GUI interface and will be a database driven application. The database used will be Derby. This application must use good Object Oriented Design and Programming. The database must use good Object-Oriented Design and Programming. There is a very close correlation between Object-Oriented Design and Database Design. Your application design should include at least four classes besides the main GUI class, e.g. Flight class, Day class..., Bookings class, etc. Your database accesses should be in the classes that correlate with the database tables. This assignment is the first half of the final project and will be submitted as Programming Assignment 6. This phase of the project will implement the following user commands:

Book Customer Day Flight The customer will be assigned the flight for the requested day, if there are seats available. If seats are not available, the customer will be put on the wait list for that flight. The waiting list must be maintained in the order the customers tried to book their flights.

Status Flight Day The Status command for flight and day will display the customers that have been booked for that flight on that day.

Status Waiting List by Day The Status command for the Waitlist will display all the customers waiting for flights on the specified day.

Database considerations: The Flight Table should be preloaded with several flights such as F101, G102 and the number of seats on the flight. Two seats per flight would be suggested to make testing easier. The Day Table should be preloaded with several days of your choice. The database tables should not contain redundant data, i.e. relevant data should only appear in one table.

GUI Guidelines: The user should be required to enter only unknown data. Drop down lists of known data such as Flight names or Days should be displayed for the user to select from. Combo Boxes should be used to categorize data on the form. When information is requested to be displayed e.g. for a Status command, all of the requested information must be displayed. When a command is performed, the results of that command should be displayed to the user without the user needing to check Status to see what was done.

Submission Guidelines:

Don't forget to submit your PROJECT files and your DATABASE files. The database files are probably located under "Users/USERNAME/.netbeansderby/NAME_OF_DATABASE". Zip the ENTIRE database folder and the ENTIRE project folder and submit the two zipped files in the dropbox under one submission.

Note: Your database and project must be created with the name ‘FlightSchedulerNameID’, where Name is your name and ID is your psu account id, e.g. xxx1234. Also, create the database with a username and password of java and java. The database when submitted for PA 6, should contain data for the flights and days tables. All other tables should be empty.

Explanation / Answer

import java.sql.*;

import javax.swing.JOptionPane;

import java.util.Calendar;

import java.awt.event.*;

import java.text.SimpleDateFormat;

public class login extends javax.swing.JFrame {

    Connection con;

    Statement smt;

    ResultSet rs;

    public static searchFrame sf;

    public static bookingFrame bookfrm;

    /**

     * Creates new form login

     */

    public login() {

        initComponents();

        javax.swing.Timer t = new javax.swing.Timer(1000, new ClockListener());

        t.start();

        this.setLocationRelativeTo(null);

        try {

            Class.forName("com.mysql.jdbc.Driver");

            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/a_r_s", "root", "");

            sf = new searchFrame();

            bookfrm = new bookingFrame();

        } catch (Exception e) {

            System.out.println(e.getMessage());

        }

}

    class ClockListener implements ActionListener {

     public void actionPerformed(ActionEvent e) {

            Calendar now = Calendar.getInstance();

            int dd = now.get(Calendar.DATE);

            int mm = now.get(Calendar.MONTH);

            int yy = now.get(Calendar.YEAR);

            int h = now.get(Calendar.HOUR_OF_DAY);

            int m = now.get(Calendar.MINUTE);

            int s = now.get(Calendar.SECOND);

            jTextField2.setText("Date : " + dd + "-" + mm + "-" + yy + " | Time : " + h + ":" + m + ":" + s);

        }

    }

    @SuppressWarnings("unchecked")

    // <editor-fold defaultstate="collapsed" desc="Generated Code">

    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();

        jLabel2 = new javax.swing.JLabel();

        jPanel1 = new javax.swing.JPanel();

        jLabel3 = new javax.swing.JLabel();

        jLabel4 = new javax.swing.JLabel();

        jButton1 = new javax.swing.JButton();

        jPasswordField1 = new javax.swing.JPasswordField();

        jTextField1 = new javax.swing.JTextField();

        jComboBox1 = new javax.swing.JComboBox();

        jLabel5 = new javax.swing.JLabel();

        jButton2 = new javax.swing.JButton();

        jTextField2 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        setTitle("JAVA AIRWAYS Ticket Reservation System");

        setResizable(false);

        jLabel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel2.setFont(new java.awt.Font("Book Antiqua", 1, 24)); // NOI18N

        jLabel2.setForeground(new java.awt.Color(200, 17, 27));

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        jLabel2.setText("Airline Reservation System");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Authentication window", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.red));

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

        jLabel3.setForeground(new java.awt.Color(0, 0, 153));

        jLabel3.setText("Your ID");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

        jLabel4.setForeground(new java.awt.Color(0, 0, 153));

        jLabel4.setText("Your Password");

        jButton1.setText("Done");

        jButton1.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jButton1ActionPerformed(evt);

            }

        });

        jPasswordField1.setToolTipText("User name is Case Sensative");

        jTextField1.setToolTipText("User name is Case Sensative");

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ADMIN", "MANAGER", "OPERATOR" }));

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

        jLabel5.setForeground(new java.awt.Color(0, 0, 153));

        jLabel5.setText("You are");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

        jPanel1.setLayout(jPanel1Layout);

        jPanel1Layout.setHorizontalGroup(

            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel1Layout.createSequentialGroup()

                .addContainerGap()

               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                    .addGroup(jPanel1Layout.createSequentialGroup()

                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addComponent(jLabel3)

                            .addComponent(jLabel5))

                        .addGap(55, 55, 55))

                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()

                        .addComponent(jLabel4)

                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                    .addGroup(jPanel1Layout.createSequentialGroup()

                        .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)

                        .addGap(18, 18, 18)

                        .addComponent(jButton1)

                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

                    .addGroup(jPanel1Layout.createSequentialGroup()

                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))

                        .addGap(0, 0, Short.MAX_VALUE))))

        );

        jPanel1Layout.setVerticalGroup(

            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()

                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jLabel5))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jLabel3))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jLabel4)

                    .addComponent(jButton1))

                .addGap(45, 45, 45))

        );

        jButton2.setText("Search flights (Login NOT Required)");

        jButton2.setActionCommand("Inquire about flights");

        jButton2.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jButton2ActionPerformed(evt);

            }

        });

        jTextField2.setEditable(false);

        jTextField2.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

        getContentPane().setLayout(layout);

        layout.setHorizontalGroup(

            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(layout.createSequentialGroup()

                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE)

                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addGroup(layout.createSequentialGroup()

                                .addGap(20, 20, 20)

                                .addComponent(jLabel1))

                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

                                .addContainerGap()

                                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))

                    .addGroup(layout.createSequentialGroup()

                        .addGap(83, 83, 83)

                        .addComponent(jButton2))

                    .addGroup(layout.createSequentialGroup()

                        .addContainerGap()

                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE)))

                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

        );

        layout.setVerticalGroup(

           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(layout.createSequentialGroup()

                .addGap(11, 11, 11)

                .addComponent(jLabel2)

                .addGap(6, 6, 6)

                .addComponent(jLabel1)

                .addGap(6, 6, 6)

                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)

                .addGap(6, 6, 6)

                .addComponent(jButton2)

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

        );

        pack();

    }// </editor-fold>

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        

        search_flight sfwl = new search_flight(this);

        sfwl.setVisible(true);

    }                                       

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        

       try {

            int flag = 0;

            String sql = "Select * from user_profile;";

            smt = con.createStatement();

            rs = smt.executeQuery(sql);

            String log = new String(jTextField1.getText());

            String pass = new String(jPasswordField1.getPassword());

            String utype = jComboBox1.getSelectedItem().toString();

            while (rs.next()) {

                if (utype.equals(rs.getString(12)) && log.equals(rs.getString(13)) && pass.equals(rs.getString(11))) {

                    flag = 1;

                    break;

                }

            }

            if (flag == 1) {

                nav_Frame navfrm = new nav_Frame(this);

                navfrm.setVisible(true);

                System.out.print(log + " " + utype + " " + pass);

            } else {

                JOptionPane.showMessageDialog(this, "Enter Correct Data ", "Acces Denied", JOptionPane.ERROR_MESSAGE);

            }

        } catch (Exception ex) {

            System.out.printf(ex.getMessage());

        }

    }                                       

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote