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
-
Hi I need help please .... I have my credit card information in my account ... But I wanted to delete & I like too add a App Store card
Hi, Ajchenicholas.
Credit cards attached to an Apple ID can be removed and payment method changed to none as long as there is not an outstanding balance. The article below will walk you through this process.
iTunes Store: Changing account information
http://support.apple.com/kb/ht1918
You can always add an iTunes Gift Card to your account at any time. Here are the steps that will walk you through adding an iTunes Gift Card.
iTunes Store: How to redeem a code
http://support.apple.com/kb/ht1574
Cheers,
Jason H. -
How can I add a new Template to My Templates in Pages? I've read most of the discussions on the subject but it doesn't work for me. By the time I reach the Templates folder, I only see templates for Numbers and not for Pages. Need help, please. Thanks
Si vous avez utilisé la commande Save As Template depuis Pages, il y a forcément un dossier
iWork > Pages
contenant Templates > My Templates
comme il y a un dossier
iWork > Numbers
contenant Templates > My Templates
Depuis le Finder, tapez cmd + f
puis configurez la recherche comme sur cette recopie d'écran.
puis lancez la recherche.
Ainsi, vous allez trouver vos modèles personnalisés dans leur dossier.
Chez moi, il y en a une kyrielle en dehors des dossiers standards parce que je renomme wxcvb.template quasiment tous mes documents Pages et wxcvb.nmbtemplate à peu près tous mes documents Numbers.
Ainsi, quand je travaille sur un document, je ne suis pas ralenti par Autosave.
Désolé mais je ne répondrai plus avant demain.
Pour moi il est temps de dormir.
Yvan KOENIG (VALLAURIS, France) mercredi 23 janvier 2011 22:39:28
iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
My iDisk is : <http://public.me.com/koenigyvan>
Please : Search for questions similar to your own before submitting them to the community -
I am trying like **** to download itunes 10.6.3 (64 bit - Windows 7) and I keep getting "the installer was interrupted before the requested operations for iTunes could be completed. Your systems has not been modified." I NEED HELP, PLEASE!
I got it figured out myself... yaaaaay for me!
-
After my iphone4S update to 7.0.6, it have a problem that keep searching network then no service show on display. Can't call. I have try check sim card, reset network settings, and restore my iphone. Still not working at all. Need help please.Urgent.TQ
Izit software or hardware? Confuse:(
Only can use wifi now.
Any way thanks guys for ur suggestion:) amishcake and simes -
Bought a new macbook and want to manually manage music onto my iphone 4s (as it is already full of music from old windows laptop) but when i click 'manually manage' and then 'apply' i get the message saying it will erase everything already on there. Need help please!
Before you sync your iPhone make sure that all the music that was synced to your phonereviously has been copied to your iTunes on the new MacBook Pro. Then when you connect your phone you will be able to either sync all music or select only those playlists that you want on the phone.
-
Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. Then I playing game I can see what someone else trying connecting to my game And I don't know what to do.So if you can help me please? I don't wanna lose my game.
Contact iTunes
Contact iTunes -
Hi i need help please i been playing clash of clans over 13 months. And today o realise what someone using my game Centra. Someone playing on my game Clash of Clans. I been change my Apple ID password, email, but doesn't work. When I playing game I can see what someone else trying connecting to my game And I don't know what to do.So if you can help me please? I don't wanna lose my game.
Hello Vaidas Vaidas,
It sounds like you are noticing someone else is accessing your Clash of Clans data by playing the game and you have tried to reset your Apple ID password. If you are following the steps outlined in this article:
Apple ID: Changing your password
http://support.apple.com/kb/ht5624
What is preventing you from changing your password? Any error messages or prompts?
Thank you for using Apple Support Communities.
All the best,
Sterling -
i dont know how i got my photos to my ipod touch from my pc and now i wanna delete them but couldn't. so need help. please let me know.
To turn off auto sync - launch iTunes and go to Edit>Preferences>Devices - check the box at the bottom that says - Prevent iPod, iPhones and iPads from syncing automatically. Click OK and then quit iTunes.
Connect your iDevice to your PC.
Launch iTunes,
Click on the device name on the left side of the iTunes Window.
Click on the Photos Tab in the iTunes window on the right.
Untick all of the photos or albums that you want to remove.
Click on Apply in the lower right corner of iTunes
If you untick or uncheck the Sync Photos heading and then click Apply it will remove all of the photos from the device when it syncs. In this screenshot - I have only certain albums and events selected to sync. -
My iPhone 6 can't find my macbook pro on the airdrop list, although everything is in place, bluetooth, wi fi gets, need help please ?
Dear Niel, thank you but my mac is (MacBook Pro (Retina, 15-inch, Early 2013).
and i can send from it to my iPhone , but not vice versa -
After many months of non-use, when I tried to open Photoshop CS4 Extended, I got an error message 148.3. "Licensing for this product has stopped working." I need help, please.
Error "Licensing has stopped working" | Windows
Error "Licensing has stopped working" | Mac OS
Mylenium -
I need help please I keep getting error messega 21 when i try uploading my iPhone 4 s!!!!!!!!! omg some one please tell me if and how to fix this please. thank you!!!
Hopefully this link will help you: http://support.apple.com/kb/HT2109
-
Hello, I,m having problems with Polish spell check. It says in iPnstruction that this App (pages) should show my writing mistakes. Check spell button is on but but check spell is not working. Need help Please.
Hello, I,m having problems with Polish spell check. It says in iPnstruction that this App (pages) should show my writing mistakes. Check spell button is on but but check spell is not working. Need help Please.
-
After updating my Iphone 5 my lock button isnt working well .... Need help please ..
First, read here:
https://ssl.apple.com/support/iphone5-sleepwakebutton/
See if your phone is affected. -
hi
i need help please . when i want to buy app from store ask me the security question
but i forgot the answer
so i need to the link to rest answer of security questionThe Best Alternatives for Security Questions and Rescue Mail
a. Send Apple an email request at: Apple - Support - iTunes Store - Contact Us.
b. Call Apple Support in your country: Customer Service: Contact Apple support.
c. Rescue email address and how to reset Apple ID security questions.
Maybe you are looking for
-
Sale Packaging Materials - VERP via Stock Transp. Order - UB, or Sales Ord.
Hi, Could you please advice is there a way to sale only packaging materials (Item Category Group: VERP)? Thanks, Marian
-
It is still on the apple loading screen for an hour already. Does anybody. Know what I can do?
-
Volume up and standby button both have double purposes
Hello, I got a problem with my iPod Touch 2G 32GB. It worked perfectly all the time, until yesterday. The buttons look like the got a second purpose. When I push the volume up button, my volume indeed goes up, BUT... after I release the button, I hea
-
FOC items received from vendor...
Hi Experts, I have a FOC item which receive from vendor. Which module i should use for good receipt? Goods Receipt PO or Goods Receipt? Thanks. Regards, Danny
-
Ditching AcrobatPro 9.4.5
I'm not a computer wizard. I'm a 'user.' When you think about the other industry that calls its customers 'users'--that would be the street drug industry--well, IT makes sense in a way it never did before, at least to me. Like tens of thousands of ot