class Question { public: Question (){} virtual float getValue () const{} virtual void setValue (char entry){} virtual void setValue (float entry){} virtual ~Question() {} }; class FiveAnswer : public Question { public: FiveAnswer (){response = -1;} FiveAnswer (char entry) {charToFloat(entry);} virtual ~FiveAnswer () {} virtual float getValue () const {return response;} virtual void setValue (char entry) {charToFloat(entry);} virtual void setValue (float entry) {} //error virtual float charToFloat (char userEntry) ; private: float response; }; float FiveAnswer::charToFloat (char userEntry) { switch(userEntry) { case 'a': case 'A': case '1': response = 1; break; case 'b': case 'B': case '2': response = 2; break; case 'c': case 'C': case '3': response = 3; break; case 'd': case 'D': case '4': response = 4; break; case 'e': case 'E': case '5': response = 5; break; default: response = -1; } return response; } class FourAnswer : public Question { public: FourAnswer (){response = -1;} FourAnswer (char entry) {charToFloat(entry);} virtual ~FourAnswer () {} virtual float getValue () const {return response;} virtual void setValue (char entry) {charToFloat(entry);} virtual void setValue (float entry) {} //error virtual float charToFloat (char userEntry) ; private: float response; }; float FourAnswer::charToFloat (char userEntry) { switch(userEntry) { case 'a': case 'A': case '1': response = 1; break; case 'b': case 'B': case '2': response = 2; break; case 'c': case 'C': case '3': response = 3; break; case 'd': case 'D': case '4': response = 4; break; default: response = -1; } return response; } class GridIn : public Question { public: GridIn () {response = -1;} virtual float getValue () const {return response;} virtual void setValue (char entry) {} virtual void setValue (float entry) ; virtual ~GridIn() {} private: float response; }; void GridIn::setValue (float entry) { if((entry < 0) || (entry >= 10000)) response = -1; else response = entry; //entry should be 4 characters long not negative }