lundi 27 juillet 2015

What is best way to refactor these series of if statements?

So I have a bunch of questions with radio buttons, each question having three options to choose from. I have a bunch of If statements ( a lot of them) that determine a final answer based on answers to each question.

For example:

Question 1 : 
           a)
           b)
           c)

Question 2 : 
           d)
           e)
           f)

Question 3 : 
           g)
           h)
           i)

and so on.

if statements will be as follows : if ( Question 1 == a || Question 2 == f && Question 3 == i )

If I want to get all the conditions as form of if statements, it'd take too much space and probably not the best practice.

What is the best way to refactor all these if statements?

Aucun commentaire:

Enregistrer un commentaire