I have a class called Masterdocument that contains different Processes. Each process contains a different number of Questions and possible answers for each question. The importance for each answer option is also mentioned in the document. Based on the response that the user provides, the main document is requested and the user's response is evaluated. Sample code is as follows.
Class Masterdocument {
vector <MasterProcess>;
};
Class MasterProcess1 {
id = 10;
num of questions = 2;
question1;
answer1option1;
answer1option2;
question1Weightage;
question2;
answer2option1;
answer2option2;
question2weightage;
//constructor
MasterProcess1(){
question1 =1;
answer1option1 =1;
answer1 option2 = 2;
question1weightage = 0.1
question2 =2;
answer2option1 = 1;
answer2option2 = 2;
question2weightage = 0.2;
}
};
Class MasterProcess2 {
id =11;
num of questions = 3;
question1;
answer1option1;
answer1option2;
question1Weightage;
question2;
answer2option1;
answer2option2;
answer2option3;
question2weightage;
question3;
answer3option1;
answer3option2;
question3weightage;
//constructor
MasterProcess2(){
question1 =1;
answer1option1 =1;
answer1 option2 = 2;
question1weightage = 0.2
question2 =2;
answer2option1 = 1;
answer2option2 = 2;
answer2option3 = 3;
question2weightage = 0.3;
question3 = 3;
answer3option1 = 1;
answer3option2 = 2;
question3weightage = 0.4
}
};
MasterDocument MasterProcesses . . ( ) . . MasterDocument, MasterProcesses , . MasterProcess1, MasterProcess2 .. MasterDocument.
( MasterProcess), , MasterProcess, , masterProcess.
, , . MasterDocument / , .
MasterProcess (, MasterProcess (id)), , MasterProcess (10) , MasterProcess (11) .
@Heisenbug
#include <iostream>
#include <utility>
#include <string>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
class BaseMasterProcess {
protected:
int processID;
int num_of_Questions;
double min_Threshold_Score_for_Process;
double total_Process_Score;
double overall_Audit_Value;
int question;
pair <int,double> answer;
int question1;
int question2;
int question3;
int question4;
int question5;
double question1_Weightage;
double question2_Weightage;
double question3_Weightage;
double question4_Weightage;
double question5_Weightage;
int passing_Score;
pair <int,double> answer1_Option1;
pair <int,double> answer1_Option2;
pair <int,double> answer1_Option3;
pair <int,double> answer2_Option1;
pair <int,double> answer2_Option2;
pair <int,double> answer2_Option3;
pair <int,double> answer3_Option1;
pair <int,double> answer3_Option2;
pair <int,double> answer3_Option3;
pair <int,double> answer4_Option1;
pair <int,double> answer4_Option2;
pair <int,double> answer4_Option3;
pair <int,double> answer5_Option1;
pair <int,double> answer5_Option2;
pair <int,double> answer5_Option3;
public:
abstract void Init();
virtual double getQuestionWeightage(int ques) = 0;
virtual double getAnswerScore(int ques, int ans) = 0;
int getNumQuestions()
{
return num_of_Questions;
}
int getProcesssID()
{
return processID;
}
double getMinThresholdScore()
{
return min_Threshold_Score_for_Process;
}
double overallAuditValue()
{
return overall_Audit_Value;
}
};
class ConcreteMasterProcess1 : public BaseMasterProcess
{
public:
void Init()
{
processID = 10;
num_of_Questions = 3;
passing_Score = 70;
min_Threshold_Score_for_Process = 0.7;
overall_Audit_Value = 0.1;
question1 = 1;
question1_Weightage = 0.3;
answer1_Option1 = make_pair (1,0.3);
answer1_Option2 = make_pair (2,0.0);
question2 = 2;
question2_Weightage = 0.3;
answer2_Option1 = make_pair (1,0.3);
answer2_Option2 = make_pair (2,0.0);
question3 = 3;
question3_Weightage = 0.4;
answer3_Option1 = make_pair (1,0.4);
answer3_Option2 = make_pair (2,0.0);
}
double getQuestionWeightage(int ques)
{
switch (ques)
{
case 1:
return question1_Weightage;
case 2:
return question2_Weightage;
case 3:
return question3_Weightage;
}
}
double getAnswerScore(int ques, int ans)
{
if (ques == question1 && ans == answer1_Option1.first)
return answer1_Option1.second;
else if (ques == question1 && ans == answer1_Option2.first)
return answer1_Option2.second;
else if (ques == question2 && ans == answer2_Option1.first)
return answer2_Option1.second;
else if (ques == question2 && ans == answer2_Option2.first)
return answer2_Option2.second;
else if (ques == question3 && ans == answer3_Option1.first)
return answer3_Option1.second;
else
return answer3_Option2.second;
}
};
class ConcreteMasterProcess2 : public BaseMasterProcess
{
void Init()
{
processID = 11;
num_of_Questions = 4;
passing_Score = 70;
min_Threshold_Score_for_Process = 0.75;
overall_Audit_Value = 0.1;
question1 = 1;
question1_Weightage = 0.25;
answer1_Option1 = make_pair (1,0.25);
answer1_Option2 = make_pair (2,0.0);
question2 = 2;
question2_Weightage = 0.25;
answer2_Option1 = make_pair (1,0.25);
answer2_Option2 = make_pair (2,0.0);
answer2_Option3 = make_pair (3,0.15);
question3 = 3;
question3_Weightage = 0.25;
answer3_Option1 = make_pair (1,0.25);
answer3_Option2 = make_pair (2,0.0);
question4 = 4;
question4_Weightage = 0.2;
answer4_Option1 = make_pair (1,0.2);
answer4_Option2 = make_pair (2,0.0);
question5 = 5;
question5_Weightage = 0.2;
answer5_Option1 = make_pair (1,0.2);
answer5_Option2 = make_pair (2,0.0);
}
double getQuestionWeightage(int ques)
{
switch (ques)
{
case 1:
return question1_Weightage;
break;
case 2:
return question2_Weightage;
break;
case 3:
return question3_Weightage;
break;
case 4:
return question4_Weightage;
break;
}
}
double getAnswerScore(int ques, int ans)
{
if (ques == question1 && ans == answer1_Option1.first)
return answer1_Option1.second;
else if (ques == question1 && ans == answer1_Option2.first)
return answer1_Option2.second;
else if (ques == question2 && ans == answer2_Option1.first)
return answer2_Option1.second;
else if (ques == question2 && ans == answer2_Option2.first)
return answer2_Option2.second;
else if (ques == question2 && ans == answer2_Option3.first)
return answer2_Option3.second;
else if (ques == question3 && ans == answer3_Option1.first)
return answer3_Option1.second;
else if (ques == question3 && ans == answer3_Option2.first)
return answer3_Option2.second;
else if (ques == question4 && ans == answer4_Option1.first)
return answer4_Option1.second;
else
return answer4_Option2.second;
}
};
class MasterDocument
{
std::vector<BaseMasterProcess*> myProcessList;
void AddProcess(BaseMasterProcess* iProcess)
{
myProcessList.push_back(iProcess);
}
void foo()
{
}
};
int main ()
{
BaseMasterProcess bmp;
ConcreteMasterProcess6 p6;
MD master_doc;
master_doc.addProcess(bmp);
master_doc.addProcess(p6);
master_doc.foo();
}
:
Init() β ISO ++ 'Init [-fpermissive]
EDIT: void Init() β RESOLVED
getQuestionWeightage (int) β - 'virtual double ConcreteMasterProcess1:: getQuestionWeightage (int): : ' {
: } β RESOLVED
main() β expected '} , unqualified-id
.: } mian() β RESOLVED
, main(). , , MasterDocument myProcssList???