annotate 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
rev   line source
rt300@24 1 //
rt300@24 2 // Question.m
rt300@24 3 // sonicZoom
rt300@24 4 //
rt300@24 5 // Created by Robert Tubb on 21/01/2013.
rt300@24 6 //
rt300@24 7 //
rt300@24 8
rt300@24 9 #import "Question.h"
rt300@24 10
rt300@24 11 @implementation Question
rt300@24 12
rt300@24 13 @synthesize questionText = _questionText;
rt300@24 14 @synthesize questionType = _questionType;
rt300@24 15 @synthesize answer = _answer;
rt300@24 16
rt300@24 17 static int theCount = 0;
rt300@41 18 // WRONG
rt300@24 19 -(id)initWithTextAndType:(NSString *)text:(QuestionType)type{
rt300@24 20 self = [super init];
rt300@24 21 if(self){
rt300@24 22 self.questionText = text;
rt300@24 23 self.questionType = type;
rt300@29 24 self.answer = -1;
rt300@24 25 }
rt300@24 26
rt300@24 27 return self;
rt300@24 28
rt300@24 29 }
rt300@24 30 ////
rt300@24 31 - (id)init
rt300@24 32 {
rt300@24 33 return [self initWithTextAndType:@"Quo Vadis?":AGREE_DISAGREE];
rt300@24 34 }
rt300@24 35
rt300@24 36 + (int) count { return theCount; }
rt300@24 37 + (void) setCount:(int)c { theCount = c; }
rt300@24 38
rt300@24 39
rt300@24 40
rt300@24 41 +(NSArray *)answersWithType:(QuestionType)type{
rt300@24 42 // get the set of answers depending on what type the q was
rt300@24 43 // pseudo static variable
rt300@24 44 if(type == AGREE_DISAGREE){
rt300@27 45 [Question setCount:NUM_CHOICES];
rt300@36 46
rt300@44 47 NSArray *answers = [[[NSArray alloc] initWithObjects:
rt300@27 48 @"Strongly agree",@"Agree", @"Neither agree nor disagree",
rt300@44 49 @"Disagree",@"Strongly disagree", nil] autorelease];
rt300@44 50
rt300@44 51 return answers;
rt300@24 52
rt300@24 53 }else if(type == SLIDERS_ZOOMER){
rt300@27 54 [Question setCount:NUM_CHOICES];
rt300@44 55 NSArray *answers = [[[NSArray alloc] initWithObjects:
rt300@31 56 @"definitely the Sliders", @"maybe the Sliders", @"Neither/Both equal",
rt300@44 57 @"maybe the Zoomer", @"definitely the Zoomer", nil] autorelease];
rt300@44 58
rt300@44 59 return answers;
rt300@24 60 }else{
rt300@24 61 return nil;
rt300@24 62 }
rt300@24 63 }
rt300@24 64 ///
rt300@24 65 @end