I need help with creating a Airlines java applet that gives the user two choices: First Class or Economy?
The system has only one airplane with 10 seats: 1 to 5 for first class and 6 to 10 for economy. The applet has two buttons and a text field for boarding pass.
If the user clicked the First Class button, a currently availabe first class seat is printed in the boarding pass.
If the user clicked the Economy button, a currently available economy seat is printed in the boarding pass.
If the user selected section has no available seat, your program should ask if the user is OK with the other section seats.
If the user clicked OK, you print the boarding pass of the assigned seat. If the user clicked Cancel, print "Next flight leaves in 3 hours"
I only have the initial buttons/field setup and am clueless on how to proceed to the next step.
I am supposed to do a boolean method that shows that when the argument is true = first class (false = economy).
Can someone please help?
Here is what I have so far...
Code
import java.awt.*; // Container, FlowLayout
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JTextField;
public class Assign7 extends JApplet implements ActionListener
{
// graphical user interface components
JButton firstClassButton, economyButton, okButton, cancelButton;
JTextField infoField;
// set up GUI components
public void init()
{
// obtain content pane and change its layout to FlowLayout
Container container = getContentPane();
container.setLayout( new FlowLayout() );
// create buttons and text fields
firstClassButton = new JButton( "First Class" );
firstClassButton.addActionListener(this);
container.add( firstClassButton );
economyButton = new JButton( "Economy" );
economyButton.addActionListener(this);
container.add( economyButton );
infoField = new JTextField(20);
infoField.setEditable(false);
container.add( infoField );
} // end method init
public int reserve(boolean firstClass)
{
}
// process button click
public void actionPerformed( ActionEvent actionEvent )
{
} // end method actionPerformed
}
This post was edited by Modification on Apr 21 2014 07:28pm