Hello,
I am trying to write a simple program that asks users yes/no questions and, based on those answers, tells them where they stand on the political spectrum.
I have a variable in my code called "questionnumber." My thought was that every time the user clicked the "nextbutton" in my IB interface, I would increase the "questionnumber" variable by 1 and thus present a new question.
This works for questions 1 and 2. But then it starts skipping every other question. Can someone tell me why? I'm stumped! The code appears below: (My IB interface buttons are keyed for "touch up inside" in case that makes a difference.)
#import "MainView.h"
#import <Foundation/Foundation.h>
@implementation MainView
@synthesize Question;
@synthesize mispar;
int conservative = 0;
int liberal = 0;
int questionnumber = 0;
- (IBAction)agreebutton

id)sender {
++liberal;
}
- (IBAction)disagreebutton

id)sender {
++conservative;
}
- (IBAction)nextbutton

id)sender {
++questionnumber;
switch (questionnumber) {
case 1:
Question.text = @"text of question 1";
break;
case 2:
Question.text = @"test of question 2";
break;
case 3:
Question.text = @"text of question 3";
break;
case 4:
Question.text = @"text of question 4";
break;
case 5:
Question.text = @"text of quesiton 5";
break;
case 6:
Question.text = @"text of question 6";
break;
case 7:
Question.text = @"text of question 7";
break;
case 8:
Question.text = @"text of question 8.";
break;
case 9:
Question.text = @"text of question 9";
break;
default:
break;
}
}
@end