view Question.m @ 49:178642d134a7 tip

xtra files
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Wed, 01 May 2013 17:34:33 +0100
parents a1e75b94c505
children
line wrap: on
line source
//
//  Question.m
//  sonicZoom
//
//  Created by Robert Tubb on 21/01/2013.
//
//

#import "Question.h"

@implementation Question

@synthesize questionText = _questionText;
@synthesize questionType = _questionType;
@synthesize answer = _answer; 

static int theCount = 0;
// WRONG
-(id)initWithTextAndType:(NSString *)text:(QuestionType)type{
    self = [super init];
    if(self){
        self.questionText = text;
        self.questionType = type;
        self.answer = -1;
    }
    
    return self;
    
}
////
- (id)init  
{
    return [self initWithTextAndType:@"Quo Vadis?":AGREE_DISAGREE];
}

+ (int) count { return theCount; }
+ (void) setCount:(int)c { theCount = c; }



+(NSArray *)answersWithType:(QuestionType)type{
// get the set of answers depending on what type the q was
    // pseudo static variable
    if(type == AGREE_DISAGREE){
        [Question setCount:NUM_CHOICES];
        
        NSArray *answers =  [[[NSArray alloc] initWithObjects:
                     @"Strongly agree",@"Agree", @"Neither agree nor disagree",
                     @"Disagree",@"Strongly disagree", nil] autorelease];

        return answers;
        
    }else if(type == SLIDERS_ZOOMER){
        [Question setCount:NUM_CHOICES];
        NSArray *answers =   [[[NSArray alloc] initWithObjects:
                 @"definitely the Sliders", @"maybe the Sliders", @"Neither/Both equal",
                @"maybe the Zoomer", @"definitely the Zoomer", nil] autorelease];

        return answers;
    }else{
        return nil;
    }
}
///
@end