-
Notifications
You must be signed in to change notification settings - Fork 0
/
answer.h
90 lines (72 loc) · 1.56 KB
/
answer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// answer.h
// abstract representation of an answer
#ifndef _ANSWER_
#define _ANSWER_
#include "getput.h"
#include <iostream>
#include <stdio.h>
#define _ANSWER_VERSION_ 1
#define NUM_ATYPES 7
#define MAX_CHOICES 10
#define MAX_EXCLUDES 16
enum ATYPE
{
SHORT_TEXT, TEXT,
CHOOSE,
INTEGER, FLOAT,
RANGE, RANK, DUMMY
};
static const char *atype_string[] =
{
"short-text", "text",
"choose",
"integer", "float",
"range", "rank", "dummy",
"SHORT-TEXT", "TEXT",
"CHOOSE",
"INTEGER", "FLOAT",
"RANGE", "RANK", "DUMMY"
};
typedef struct tp_choice *P_tp_choice;
struct tp_choice
{
char *text;
int num_excludes;
char *excludes[MAX_EXCLUDES];
};
typedef class ANSWER *P_ANSWER, **PP_ANSWER;
class ANSWER {
public:
ANSWER();
~ANSWER();
void set_version();
// functions used by the scanner
void settype(char *newtype);
void settype(ATYPE newtype);
void setminch(int minch);
void setmaxch(int maxch);
void addexclude(char *txt);
void addchoice(char *txt);
// functions used by the survey tool
int getnumch();
int getminch();
int getmaxch();
P_tp_choice getchoices();
const char *get_type();
ATYPE get_atype();
void print();
void panswer();
void pversion();
void readFromDisk(FILE *fp);
void writeToDisk(FILE *fp);
// the data
private:
char *BigStrTmp;
int version;
ATYPE answer_type;
int num_choices;
int min_pick;
int max_pick;
tp_choice choices[MAX_CHOICES];
};
#endif