I am writing a program that asks users yes/no questions to help them decide how to vote in an election. I have a variable representing the question number called questionnumber. Each time I go through the switch-break loop, I add 1 to the questionnumber variable so that the next question will be displayed.
This works fine for the first two questions. But then it skips the third question and moves on to the fourth. When I have more questions in the list, it skips every other question. Somewhere, for some reasons, the questionnumber variable is increasing when I don't want it to.
Please look at the code below and tell me what I'm doing wrong.
Thank you!
Eli
#import "MainView.h"
#import <Foundation/Foundation.h>
@implementation MainView
@synthesize Question;
@synthesize mispar;
int conservative = 0;
int liberal = 0;
int questionnumber = 1;
- (IBAction)agreebutton:(id)sender { ++liberal; }
- (IBAction)disagreebutton:(id)sender { ++conservative; }
- (IBAction)nextbutton:(id)sender
{
++questionnumber;
switch (questionnumber)
{
case 2: Question.text = @"Congress should ...."; break;
case 3: Question.text = @"It is not fair ..."; break;
case 4: Question.text = @"There are two ..."; break;
case 5: Question.text = @"Top quality h..."; break;
default: break;
}
}
@end