dimanche 16 juillet 2017

How to avoid if conditions depending of options

I am working on a quiz app and I have a problem that I would like to resolve for futures similar problems.

Concrete case: My app has two options (the second one is chained with first one): "show response" and "try again". If the "show response" option is selected, when you touch some answer, it's will painted by some color that depends if the answer is correct or not and, in the case of error response, the app will mark the correct answer too, and all options will be disabled to touch. If "try again" option is selected (only it can selectable if show response is selected), the app will works like the before option, but it doesn't show the correct answer at this moment (of course, only if you touched the correct answer) and it gives you the chance to choose again (without unpaint the answer touched previously), until select the correct answer. In opposition, if you haven't selected the show response option, when you touch the answer it will be painted with some color indicating that you selected it.

What is the best solution for resolve this kind of problem when you have many if else and each condition has subconditions and/or its share some action.

(PD: Sorry for my English mistakes)

Aucun commentaire:

Enregistrer un commentaire