This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Setting Parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Setting Parameters" Watch "Setting Parameters" New topic
Author

Setting Parameters

Fonzworth Campbell
Greenhorn

Joined: Nov 17, 2009
Posts: 1
I am doing a small Java program for a smaller scale oyster card.

On my train line i have 20 stations but i accidentally entered 400 in the dialogue box only to find out that it still runs the program,. im unsure of how to set it so only these 20 stations are selected and if another is chosen then a error message is printed.

any help would be much appreciated

thank you

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Welcome to the Ranch.

A few things to help you get started on the best foot.

1) Please be sure to take the time to compose descriptive subjects for your posts; read this for more information.

A title such as "Need Urgent Help" is not useful. What would happen if all posts had such a title?

Please go back and change your post to add a more meaningful subject by clicking the button on your post.

2) Please read this.

Good luck with your question.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11161
    
  16

you have to validate what the user inputs. They will be able to input whatever they want. your job is to store it (which I assume you are doing). then you need to test it to see if it's valid. if so, your program may proceed. if it's NOT valid, you can have your program quit, have it say "20 is the largest, I'll use that", you can give them another chance to do it, or anything else you want.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting Parameters
 
Similar Threads
XM Radio
is streamripping illegal?If not anyone ever try to code one?
High Gas Prices
Help with IF statements
Radio preset buttons