Switch method need help please ;-(

Hello, I am having trouble with this switch method. I have yet ot construct the AirplaneList object "plane". For I have yet to be taught about it properly
Can someone at least help me with the switch incident. I have learnt how to make a menu for the user to input the letters A-F in uppercase and lower case. However I am unsure on how to associate "case a" to the method
//add Airplane
public static void option1 (AirplaneList plane)
? I can get it to print out "case a" continueosly, but how to I associate it to the method. I am aware that the AirplaneList will be a class I have to define earlier, and that "plane" is an object I will need to intiate. If anyone will be willing to help me construct this part of the code I can award them Duke dollars.
as far as I can tell the constructor method would start off like
AirplaneList plane = new AirplaneList;
ok? then what do I do?
do I define its methods then?
plane.add()
Ok well this is the majority of the code I have already.
import javax.swing.JOptionPane; //indicates that the compiler should load class JOptionPane for use in this application.
public class AirplaneListT
     public static void main (String[] args)
throws java.io.IOException
          char choice; //Words choice and size are the names of variables
     //     int size; //This declaration specifies that the variable are of data type char and int
     //     size = EasyIn.getInt(); // Converts size from int to something?
     //Char - a variable that may only hold a single lowercase letter, a single uppercase letter, a single digit or a special character
//(such as x, $, 7 and *)
     // The code below creates a dialog box for the user to input a choice
     String inputcode;
     inputcode = JOptionPane.showInputDialog("A: add an airplane from the list\n" +
                              "B: remove an airplane from the list\n" +
                              "C: check if the list is empty\n" +
                              "D: check if the list is full\n" +
                              "E: display the list\n" +
                              "F: quit\n" );
     JOptionPane.showMessageDialog(null, "You have chosen choice " + inputcode);
//The null first argument indicates that the message dialog will appear in the center of the screen. The 2nd is the message to display
do
     // get choice from user
     choice = inputcode.toUpperCase().charAt(0);
          System.out.println();
          //process menu options
          switch(choice)
               case 'A':
               case 'a':
                    JOptionPane.showMessageDialog(null, "Case " + inputcode);
                    break;     //done processing case
               case 'B':
               case 'b':
                    JOptionPane.showMessageDialog(null, "Case " + inputcode);
                    break;     //done processing case
               case 'C':
               case 'c':
                    JOptionPane.showMessageDialog(null, "Case " + inputcode);
                    break;     //done processing case
               case 'D':
               case 'd':
                    JOptionPane.showMessageDialog(null, "Case " + inputcode);
                    break;     //done processing case
               case 'E':
               case 'e':
                    JOptionPane.showMessageDialog(null, "Case " + inputcode);
                    break;     //done processing case
               case 'F':
               case 'f':
                    JOptionPane.showMessageDialog(null, "Case " + inputcode);
                    break;     //done processing case
               default:
                    JOptionPane.showMessageDialog(null, "Invalid entry!");
                    break;     //done processing case
     }while (choice!= 'F' || //end AirplaneList tester
     choice!= 'f' );
//add Airplane
     public static void option1 (AirplaneList plane)
          String flight;
          flight = JOptionPane.showInputDialog("Please enter airplane filght number" );
          //create an Airplane object to add to list
          Airplane flight = new Airplane();
          //add string to list if the list is not full
          //access the 'add(Airplane)' method from the AirplaneList class;
          //if the list is full, return a statement to the user indicating that no more plane can be added onto the list
     //remove airplane
     public static void option2 ()
          //get position of item
     string enterpos;
     enterpos = JOptionPane.showInputDialog("Please enter position to remove" );
          System.out.print(":")
          int plane = Easyln.getint();
          // delete item if it exists
          //access the 'remove(Airplane)' method from the AirplaneList class;
          //if the user enter an invalid number for the position, returen a statement
          //indicating that there is no such posititon.
     //check if empty
     public static void option3 (AirplaneList plane)
          if (plane.isEmpty())
               JOptionPane.showInputDialog("list is empty" );
          else
               JOptionPane.showInputDialog("list is not empty" );
     //check if full
     public static void option4 (AirplaneList plane)
          if (plane.isFull())
               JOptionPane.showInputDialog("list is full" );
          else
               JOptionPane.showInputDialog("list is not full" );
     //display list
     public static void option5 (AirplaneList plane)
          if (plane.isEmpty())     //no need to display if list is empty
               JOptionPane.showInputDialog("list is empty" );
          else
               JOptionPane.showInputDialog("Airplanes in list are" );
               //loop through list
     System.exit(0); //Terminates the program

case 'A':
case 'a':
JOptionPane.showMessageDialog(null, "Case " + " + inputcode);
break;     //done processing case
ok are u saying if i invoke a method i go something
like this?
case 'A':
case 'a':
JOptionPane.showMessageDialog(null, "Case " + " + inputcode);
AirplaneList.option1(); //Tell Airplanelist to add                    
break;     //done processing caseIn both cases, you're calling methods. In the latter case, you're calling two methods.
What's the problem exactly? What part are you having trouble with?
... so that then when case a is activated it should go
onto option1 method?That's one thing you can do, yes. I don't know if you should do it. It depends on what your program needs to do.
//add Airplane
     public static void option1 (AirplaneList plane)
          String flight;
flight = JOptionPane.showInputDialog("Please enter
r airplane filght number" );
          //create an Airplane object to add to list
          Airplane flight = new Airplane();
          //add string to list if the list is not full
//access the 'add(Airplane)' method from the
e AirplaneList class;
//if the list is full, return a statement to the
e user indicating that no more plane can be added onto
the list
     }OK, this looks odd. Is this what you're having trouble with?
BTW, I'd strongly suggest making a stronger separation of application code from GUI code.

Similar Messages

Maybe you are looking for