vendredi 7 mai 2021

Checking if multiple inputs are within range

Let's say the user inputs multiple numbers: height, weight, speed, etc...

I want to check if height is between 150 and 200 and if not throw an error. I also want to check if weight is between 50 and 100 and if not throw an error. Same thing for speed and so on.

Now I could have a bunch of if statements that individually check for each condition and have an error corresponding to each, but is there a more condensed and cleaner way to do this?

Aucun commentaire:

Enregistrer un commentaire