• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting Parameters

 
Fonzworth Campbell
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic