Look at your code: what you have is this:
if (x == 0)
foo();
if (x == 1)
bar();
else if (x == 2)
foobar();
Or later this:
if (x == 0)
foo();
switch (x)
case 1:
bar();
break;
case 2:
foobar();
break;
If
x
is equal to zero, it cannot at the same time be equal to one or two. You need to restructure your code so that the values can be checked properly - changing test constructs won't do that when its; teh whole structure that is wrong.
if (x == 0)
foo();
if (x == 1)
bar();
else if (x == 2)
foobar();
Or this:
if (x == 0)
foo();
else if (x == 1)
bar();
else if (x == 2)
foobar();
Or perhaps this:
switch (x)
case 0:
foo();
break;
case 1:
bar();
break;
case 2:
foobar();
break;