Hey i have a project that i have put the Questation at the end of this message i am a newbie to java and have make this my mainly Questation how do i put somethin in my arrays from GUI ?? and how do i search in name or id in array ?? or and print out the array ?? plzz help
best and warm regard boom

Main.java

package ferryticketsystem;

/**
 *
 * @author s072762
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
//        char P, V, Q;
//
//        System.out.println("\b Main Menu"); // Display the string.
//
//        System.out.println("");


        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new GUI().setVisible(true);
            }
        });

//        public class ReallyQuitDialog extends YesNoDialog {
//    TextComponent status;
//    // Create the kind of YesNoDialog we want
//    // And store away a piece of information we need later.
//    public ReallyQuitDialog(Frame parent, TextComponent status) {
//        super(parent, "Really Quit?", "Really Quit?", "Yes", "No", null);
//        this.status = status;
//    }
//    // Define these methods to handle the user's answer
//    public void yes() { System.exit(0); }
//    public void no() {
//        if (status != null) status.setText("Quit cancelled.");
//    }
//}

    }
}

FerryDataholder.java

package ferryticketsystem;

public class FerryDataHolder {

    //Initialize parameters
    private int ID = 0;
    private boolean[] businessClassSeats = {false, false, false, false, false, false, false, false, false, false};
    private boolean[] economyClassSeats = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
    private int seatNumber = 0;

    public FerryDataHolder(int ID) {
        this.ID = ID;
    }

    public int getID() {
        return ID;
    }


    private boolean isBusinessSeatAvailable() {   //True = Yes!
        for (int i = 0; seatNumber < businessClassSeats.length; ++i) {
            if (businessClassSeats[i] == false) {
                seatNumber = i + 1;
                return true;
            }
        }
        return false;
    }

    private boolean isEconomySeatAvailable() {   //True = Yes!
        for (int i = 0; seatNumber < economyClassSeats.length; ++i) {
            if (economyClassSeats[i] == false) {
                seatNumber = i + 1;
                return true;
            }
        }
        return false;
    }

    //Returns 'true' if success
    public boolean makeEconomySeatReservation(){
        seatNumber = -1;
        if(isEconomySeatAvailable()){
            economyClassSeats[seatNumber-1] = true;
            return true;
        }
        return false;
    }
///ahmed
     public boolean makeBuisnessSeatReservation(){
        seatNumber = -1;
        if( isBusinessSeatAvailable()){
           businessClassSeats[seatNumber-1] = true;
            return true;
        }
        return false;
    }

///

    public int getSeatNumber() {
        return seatNumber;
    }

}

gui.java

package ferryticketsystem;

import java.util.HashMap;

public class GUI extends javax.swing.JFrame {

    private HashMap<Integer, String> passengerList = new HashMap<Integer, String>();
    private HashMap<Integer, FerryDataHolder> ferries;
    /** Creates new form GUI */
    public GUI() {
        initComponents();
        initParam();
    }

    private void initParam() {
        jTabbedPane1.setMnemonicAt(0, 'M');
        jTabbedPane1.setMnemonicAt(1, 'P');
        jTabbedPane1.setMnemonicAt(2, 'V');
        quitButton.setMnemonic('Q');

        //Init ferries
        ferries = new HashMap<Integer, FerryDataHolder>();

        ferries.put(1, new FerryDataHolder(1));
        ferries.put(2, new FerryDataHolder(2));
        ferries.put(3, new FerryDataHolder(3));
        ferries.put(4, new FerryDataHolder(4));
        ferries.put(5, new FerryDataHolder(5));
        ferries.put(6, new FerryDataHolder(6));
        ferries.put(7, new FerryDataHolder(7));
        ferries.put(8, new FerryDataHolder(8));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        quitButton = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        label1 = new java.awt.Label();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel1.setText("Ferry Ticketing System");

        jLabel2.setText("Press Alt + 'P' to purchase ticket");

        jLabel3.setText("Press Alt + 'V' to View seating arrangement");

        jLabel4.setText("Press Alt + 'Q' to Quit the system");

        quitButton.setText("Quit");
        quitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quitButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4))
                .addContainerGap(154, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(303, Short.MAX_VALUE)
                .addComponent(quitButton)
                .addGap(51, 51, 51))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(126, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(102, 102, 102))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(49, 49, 49)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                .addComponent(quitButton)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Main", jPanel1);

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel5.setText("Purchasing Module");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel7.setText("Buy:");

        jLabel8.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel8.setText("Press Alt + 'M' to return to main menu");

        jButton1.setText("Purchase ticket for Buisness class");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Purchase ticket for Economy class");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(135, Short.MAX_VALUE)
                .addComponent(jLabel5)
                .addGap(124, 124, 124))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(jLabel7)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton2)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jButton1)
                                .addGap(205, 205, 205)
                                .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addComponent(jLabel7)
                .addGap(22, 22, 22)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addGap(31, 31, 31)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
                .addComponent(jLabel8)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Purchase Tickets", jPanel2);

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18));
        jLabel6.setText("Seating Arrangement");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(127, Short.MAX_VALUE)
                .addComponent(jLabel6)
                .addGap(115, 115, 115))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addContainerGap(193, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Seating Arrangement", jPanel3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 412, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void quitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quitButtonActionPerformed
        System.exit(0);
    }//GEN-LAST:event_quitButtonActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private java.awt.Label label1;
    private javax.swing.JButton quitButton;
    // End of variables declaration//GEN-END:variables
}

FERRY TICKETING SYSTEM
A small ferry company has just purchased a computer for its new automated ticketing system. The company director has asked you to design the new system to assign seats for each trip of the 50-seater ferry, which covers the route from Penang to Langkawi and back daily. The upper deck of the ferry is reserved for business class passengers and can accommodate 10 people. The main deck of the ferry, the economy class can accommodate 40 people. Assume the company has at least 8 ferries - each with a different Ferry ID, which travel at one-hour intervals from 10 am to 5 pm daily.
SECTION A : BASIC REQUIREMENTS OF THE SYSTEM
1. Main Menu
Your initial program design should display the following menu alternatives: FERRY TICKETING SYSTEM
P – to Purchase Ticket V –to View Seating Arrangement Q – to Quit the system
2. Submenu
The following submenu will be displayed when P is selected: PURCHASING MODULE B – to purchase ticket for Business class E – to purchase ticket for Economy class M – to return to Main Menu
3. Assigning Seats
If the person types B, then your program should assign a seat in the business class (seats 1-10). If the person types E, then your program should assign a seat in the economy class (seats 11 - 50).
4. Boarding Ticket Your program should then print a boarding ticket indicating the person’s name, seat number, whether it is in the business or economy class of the ferry, Date and time of departure, Source and Destination of the trip and Ferry ID.
5. Seating Chart
Use single-scripted array to represent the seating chart of the ferry, indicating the availability of the seats within each trip of the ferry. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seat is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available. Your program should never assign a seat that has already been assigned. The Ferry ID will be requested when V is selected from the main menu and the seating arrangement for that ferry will be displayed in a tabular form, e.g. ************************************************************* * Ferry ID : 007 Date: 19 Sept 2005 * ************************************************************* * BUSINESS CLASS * ************************************************************* * 1 * 1 * 1 * 0 * 0 * ************************************************************* * 0 * 0 * 0 * 0 * 0 * ************************************************************* * ECONOMY CLASS * ************************************************************* * 1 * 1 * 1 * 1 * 1 * ************************************************************* * 1 * 1 * 1 * 1 * 1 * ************************************************************* * 0 * 0 * 0 * 0 * 0 * ************************************************************* * 0 * 0 * 0 * 0 * 0 * ************************************************************* * 0 * 0 * 0 * 0 * 0 * ************************************************************* * 0 * 0 * 0 * 0 * 0 * ************************************************************* * 0 * 0 * 0 * 0 * 0 * ************************************************************* * 0 * 0 * 0 * 0 * 0 * *************************************************************
6. Alternative seating When the business class is full, your program should ask the person if it is acceptable to be placed in the economy class (and vice versa). If yes, then make the appropriate seat assignment. If no, then print the message “Next trip leaves in 1 hour”.

Try to give relevant title next time.

Try to give relevant title from next time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.