#include "iostream.h"

#ifndef QUESTION_CPP
#define QUESTION_CPP
#include "question.cpp"
#endif

class Section
{
public:
      Section(){}
      Section (int fiveAnswerChoices, int fourAnswerChoices, int gridIns);
      float getAnswer(int questionNumber) {return pArray[questionNumber].getValue();}
private:
      Question * pArray;
      char * pFiveString;
      char * pFourString;
  		float valueOfGridIn;
      GridIn * pGridIn;
      FourAnswer * pFourAnswer;
      FiveAnswer * pFiveAnswer;
};


Section::Section (int fiveAnswerChoices, int fourAnswerChoices, int gridIns)
{
	pArray = new Question[fiveAnswerChoices+ fourAnswerChoices + gridIns];
   if(fiveAnswerChoices)     //NOT ZERO
   {
      //new textfield(length 5's)
      pFiveString = new char[fiveAnswerChoices];
      cin.unsetf(ios::skipws); //don't skip white spaces
      cin.get(pFiveString, fiveAnswerChoices);
      for (int x = 0; x < fiveAnswerChoices; x++)
      {
      	pFiveAnswer = new FiveAnswer;
         pFiveAnswer->setValue(pFiveString[x]);
         pArray[x] = * pFiveAnswer;
         delete pFiveAnswer;
      }
   }

   if(fourAnswerChoices)        //not zero
   {
		//new textfield(length 4's)
      pFourString = new char[fourAnswerChoices];
      cin.unsetf(ios::skipws); //don't skip white spaces
      cin.get(pFourString, fourAnswerChoices);
      for (int x = 0; x < fourAnswerChoices; x++)
      {
       	pFourAnswer = new FourAnswer;
         pFourAnswer->setValue(pFourString[x]);
         pArray[fiveAnswerChoices + x] = * pFourAnswer;
         delete pFourAnswer;
      }
   }

   if(gridIns)  //not zero
   {
      //create gridIns # of textfields
		for (int x=0; x < gridIns; x++)
      {
	      cin >> valueOfGridIn ;
         cout << "\n";
			pGridIn = new GridIn;
         pGridIn->setValue(valueOfGridIn);
   	   pArray[fiveAnswerChoices + fourAnswerChoices + x] = * pGridIn;
         delete pGridIn;
      }
   }
}
1