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.
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