#urgent, boolean input validation

18 messages · Page 1 of 1 (latest)

fringe anvilBOT
#

This post has been reserved for your question.

Hey @quiet anchor! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

jade badger
#

you already are validating boolean only input, you're not enforcing it, which isn't possible given the environment of the console.
instead, catch the error and loop to reprompt the user.

also, consider
a) prompting with true and false instead of True and False
b) prompting for y/n instead

quiet anchor
jade badger
#

that doesn't catch any error at all

#

maybe uh. don't guess what i mean when i say "catch the error"

#

if you don't understand it, say so.

quiet anchor
#

okay, thanks for the rude comment. i came here for help not a smart ass.

jade badger
#

reserved != true || false is just checking that reserved is false.
the "correct" way to write this would be reserved != true && reserved != false, fyi, but this is kinda a useless statement

#

when you input some invalid boolean, the scnr.nextBoolean() will have given you an InputMismatchException, and you need to catch that, there's a special way to do it explained there ^

#

you would need to loop to keep reprompting if the user continues inputting nonbooleans

quiet anchor
#

thanks for the actual advice, now for my bit of advice.. when someone who states they need help (aka not a professional or perfect) that means if you're going to comment. help. don't criticize. if i was asking for critiques i would have said so. you will go nowhere in life with the attitude you brought previous to the actual help. all you had to say was "that doesnt catch any error at all, heres a link i think could help you". now we've both learned something today, crazy!

jade badger
#

i literally did give you advice though

quiet anchor
#

goodbye

jade badger
#

asking when you don't understand is incredibly important when asking for help

#

alright sure buddy

#

all ive learned is that wow, angry people get quite stupid.